Skip to content

Instantly share code, notes, and snippets.

@Nilanth

Nilanth/.jsx Secret

Created July 17, 2021 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nilanth/3a9c07204b126fa00e91ead2f07ee46f to your computer and use it in GitHub Desktop.
Save Nilanth/3a9c07204b126fa00e91ead2f07ee46f to your computer and use it in GitHub Desktop.
create slice
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