Created
March 31, 2019 12:14
-
-
Save madan712/ef2feb88b04cdd5d93a35a93760cd3af to your computer and use it in GitHub Desktop.
AppReducer.js - Simple React + Redux example
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
const initialState = { | |
count: 0 | |
}; | |
export default function AppReducer(state = initialState, action) { | |
const newState = Object.assign({}, state); | |
switch (action.type) { | |
case 'INCREMENT': | |
newState.count = newState.count + 1; | |
return newState; | |
case 'DECREMENT': | |
newState.count = newState.count - 1; | |
return newState; | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment