UNPKG

cra-template-ipt-sun-redux

Version:

The base template for Create React App with Redux folder structure dedicated for the creator of this template.

30 lines (25 loc) 652 B
import { createSlice } from "@reduxjs/toolkit"; const initialState = { count: 0, }; export const counterSlice = createSlice({ name: "counter", initialState, reducers: { increment: (state) => { state.count += 1; }, decrement: (state) => { state.count -= 1; }, incrementByAmount: (state, action) => { state.count += action.payload; }, decrementByAmount: (state, action) => { state.count -= action.payload; }, }, }); export const { increment, decrement, incrementByAmount, decrementByAmount } = counterSlice.actions; export default counterSlice.reducer;