Skip to content

Instantly share code, notes, and snippets.

@daniele-zurico
Last active January 10, 2019 16:05
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 daniele-zurico/523abe03fb05237b232c3e34334df779 to your computer and use it in GitHub Desktop.
Save daniele-zurico/523abe03fb05237b232c3e34334df779 to your computer and use it in GitHub Desktop.
const todoListReducer = (
state: string[],
action: { type: string; value: string }
) => {
switch (action.type) {
case "ADD":
return [...state, action.value];
case "REMOVE":
return state.filter((todo: string) => todo !== action.value);
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment