Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const INCREMENT = 'INCREMENT'; // define a constant for increment action types
- const DECREMENT = 'DECREMENT'; // define a constant for decrement action types
- const counterReducer = (state = 0, action) => {
- switch(action.type) {
- case INCREMENT:
- return state + 1
- case DECREMENT:
- return state - 1
- default:
- return state;
- }
- }; // define the stateer reducer which will increment or decrement the state based on the action it receives
- const incAction = state => {
- return {
- type: INCREMENT
- }
- } // define an action creator for incrementing
- const decAction = state => {
- return {
- type: DECREMENT
- }
- }; // define an action creator for decrementing
- const store = Redux.createStore(counterReducer); // define the Redux store here, passing in your reducers
Add Comment
Please, Sign In to add comment