Skip to content

Instantly share code, notes, and snippets.

@slashpot
Created August 10, 2020 14:23
Show Gist options
  • Save slashpot/0b84c03e282343ec128f5fb17e997fe4 to your computer and use it in GitHub Desktop.
Save slashpot/0b84c03e282343ec128f5fb17e997fe4 to your computer and use it in GitHub Desktop.
export const counterReducer = (state, action) => {
switch (action.type) {
case 'increment':
return {
...state,
count: state.count + 1
};
case 'decrement':
return {
...state,
count: state.count - 1
};
default:
return {
...state
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment