Skip to content

Instantly share code, notes, and snippets.

@fxck
Created September 12, 2018 09:34
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 fxck/7f210c6166a360ac8bfa6422f88d7d64 to your computer and use it in GitHub Desktop.
Save fxck/7f210c6166a360ac8bfa6422f88d7d64 to your computer and use it in GitHub Desktop.
export function reducer(
state = initialState,
action: Actions
) {
switch (action.type) {
case ActionTypes.Add:
return { data: [ ...state.data, action.payload ] };
case ActionTypes.Remove:
return { data: state.data.filter((id) => id !== action.payload) };
}
return state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment