Skip to content

Instantly share code, notes, and snippets.

@idmontie
Created April 17, 2018 23:54
Show Gist options
  • Save idmontie/bda6f1f672e2d6efb60c8a75a1f33144 to your computer and use it in GitHub Desktop.
Save idmontie/bda6f1f672e2d6efb60c8a75a1f33144 to your computer and use it in GitHub Desktop.
(state, action) => {
switch (action.type) {
case TOGGLE: {
const count = state.count || 0;
const isOn = count < 4 ? action.changes.on : false;
return {
...state,
...action.changes,
count: isOn ? count + 1 : count,
on: isOn,
};
}
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment