Last active
September 10, 2018 15:13
-
-
Save sathinduga/4449fe01f895111fba9d8a95fc41fb28 to your computer and use it in GitHub Desktop.
Reducer
This file contains hidden or 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 { COUNTER_ADD, COUNTER_SUBTRACT } from "../actions/action_types"; | |
| const initialState = { | |
| count: 0 | |
| }; | |
| const counterReducer = (state = initialState, action) => { | |
| switch (action.type) { | |
| case COUNTER_ADD: | |
| return { | |
| ...state, | |
| count: state.count + 1 | |
| }; | |
| case COUNTER_SUBTRACT: | |
| return { | |
| ...state, | |
| count: state.count - 1 | |
| }; | |
| default: | |
| return state; | |
| } | |
| }; | |
| export default counterReducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment