Skip to content

Instantly share code, notes, and snippets.

@baptistemanson
Created July 20, 2017 18:01
Show Gist options
  • Save baptistemanson/09d037d0816f1e4c08d6b9b0fbdfee2e to your computer and use it in GitHub Desktop.
Save baptistemanson/09d037d0816f1e4c08d6b9b0fbdfee2e to your computer and use it in GitHub Desktop.
const ADD = 'my-app/users/ADD';
export default function reducer(state = {}, action = {}) {
switch (action.type) {
ADD: return {...state, [action.payload.id]: action.payload}
default: return state;
}
}
// Action Creators
export function addUser(payload) {
return { type: ADD, payload };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment