Skip to content

Instantly share code, notes, and snippets.

@madan712
Created March 31, 2019 12:14
Show Gist options
  • Save madan712/ef2feb88b04cdd5d93a35a93760cd3af to your computer and use it in GitHub Desktop.
Save madan712/ef2feb88b04cdd5d93a35a93760cd3af to your computer and use it in GitHub Desktop.
AppReducer.js - Simple React + Redux example
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