Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created February 1, 2021 22:38
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 AllGistsEqual/fdd308fbc37dc7358539680b4544c4a7 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/fdd308fbc37dc7358539680b4544c4a7 to your computer and use it in GitHub Desktop.
// 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