Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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