Skip to content

Instantly share code, notes, and snippets.

@alexmochu
Last active July 22, 2020 07:45
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 alexmochu/50a262d0a8c246ea07cf40c3b6354357 to your computer and use it in GitHub Desktop.
Save alexmochu/50a262d0a8c246ea07cf40c3b6354357 to your computer and use it in GitHub Desktop.
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