Skip to content

Instantly share code, notes, and snippets.

@alexmochu
Last active Jul 22, 2020
Embed
What would you like to do?
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
type CurrentDisplayState = {
clicks: number
}
let initialState: CurrentDisplayState = {
clicks: 0,
}
const countSlice = createSlice({
name: 'count',
initialState,
reducers: {
addCount(state, action: PayloadAction<number>) {
state.clicks += action.payload
},
minusCount(state, action: PayloadAction<number>) {
state.clicks -= action.payload
}
}
})
export const {
addCount,
minusCount
} = countSlice.actions
export default countSlice.reducer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment