Created
February 1, 2021 22:38
-
-
Save AllGistsEqual/fdd308fbc37dc7358539680b4544c4a7 to your computer and use it in GitHub Desktop.
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
// File: src/redux/demo/counter.ts | |
import { createSlice, PayloadAction } from '@reduxjs/toolkit' | |
const initialState = 0 | |
const counterSlice = createSlice({ | |
name: '[DEMO] counter', | |
initialState, | |
reducers: { | |
increment: (state, action: PayloadAction<number>) => state + action.payload, | |
decrement: (state, action: PayloadAction<number>) => state - action.payload, | |
}, | |
}) | |
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