create-next-core-base
Version:
CLI tool to create Next Base projects with feature selection
31 lines (25 loc) • 766 B
text/typescript
import { CounterState } from "@/store/slice/counter/counterSliceType";
import { createSlice } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";
const initialState: CounterState = {
value: 0,
};
export const counterSlice = createSlice({
name: "counter",
initialState,
reducers: {
increment: (state) => {
state.value += 1;
},
decrement: (state) => {
state.value -= 1;
},
incrementByAmount: (state, action: PayloadAction<number>) => {
state.value += action.payload;
},
},
});
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
export const selectCount = (state: { counter: CounterState }) =>
state.counter.value;
export default counterSlice.reducer;