Skip to content

Instantly share code, notes, and snippets.

@i-oliva
Created October 1, 2018 15:59
Show Gist options
  • Save i-oliva/c51cf8ee1552ecc19adac62defc78fe6 to your computer and use it in GitHub Desktop.
Save i-oliva/c51cf8ee1552ecc19adac62defc78fe6 to your computer and use it in GitHub Desktop.
const reducer = (state, action) => {
const { results } = state;
switch (action.type) {
case 'DELETE_ELEMENT':
return {
...state,
results: results.filter(result => {
return result.email !== action.payload;
})
};
case 'ADD_CONTACT':
return {
...state,
localUsers: [action.payload, ...state.localUsers]
};
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment