Skip to content

Instantly share code, notes, and snippets.

@dceddia
Created November 17, 2017 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dceddia/68bfd12ba01916cdd48c080fd7051114 to your computer and use it in GitHub Desktop.
Save dceddia/68bfd12ba01916cdd48c080fd7051114 to your computer and use it in GitHub Desktop.
function brokenReducer(state = initialState, action) {
switch(action.type) {
case 'INCREMENT':
// NO! BAD: this is changing state!
state.count++;
return state;
case 'DECREMENT':
// NO! BAD: this is changing state too!
state.count--;
return state;
default:
// this is fine.
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment