Skip to content

Instantly share code, notes, and snippets.

@adedayojs
Created January 17, 2020 13:51
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 adedayojs/07725fa05cae44b9510234832c8b99f0 to your computer and use it in GitHub Desktop.
Save adedayojs/07725fa05cae44b9510234832c8b99f0 to your computer and use it in GitHub Desktop.
counterReducer = (state, action) => {
switch (action.type) {
case 'INCREASE':
return { ...state, count: state.count + 1 };
case 'DECREASE':
return { ...state, count: state.count - 1 };
default:
return state;
}
};
/*
This kind of reducer above doesn't make use of any payload
in the action so supplying a payload in the action is not needed.
That is why i said payload is optional.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment