Created
May 13, 2019 13:55
-
-
Save sahoosunilkumar/17e9754cce75d53f8eb41b0a1d26d0af 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 { INCREMENT, DECREMENT } from "../actions/types"; | |
const initialState = { | |
counter: 0 | |
}; | |
const counterReducer = (state = initialState, action) => { | |
switch (action.type) { | |
case INCREMENT: | |
return { | |
...state, | |
counter: Number(state.counter) + Number(action.payload) | |
}; | |
case DECREMENT: | |
return { | |
...state, | |
counter: Number(state.counter) - Number(action.payload) | |
}; | |
default: | |
return state; | |
} | |
}; | |
export default counterReducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment