Last active
July 22, 2020 07:45
-
-
Save alexmochu/50a262d0a8c246ea07cf40c3b6354357 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
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