Last active
September 10, 2018 15:13
Reducer
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 { 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