-
-
Save Nilanth/3a9c07204b126fa00e91ead2f07ee46f to your computer and use it in GitHub Desktop.
create slice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSlice } from '@reduxjs/toolkit' | |
const initialState = { value: 0 } | |
const counterSlice = createSlice({ | |
name: 'counter', | |
initialState, | |
reducers: { | |
increment(state) { | |
state.value++ | |
}, | |
decrement(state) { | |
state.value-- | |
}, | |
}, | |
}) | |
export const { increment, decrement } = counterSlice.actions | |
export default counterSlice.reducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment