Skip to content

Instantly share code, notes, and snippets.

@janusch
Created September 4, 2015 09:22
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 janusch/8e50fc205b2d0a9448f6 to your computer and use it in GitHub Desktop.
Save janusch/8e50fc205b2d0a9448f6 to your computer and use it in GitHub Desktop.
reducer add to object in object array
case GET_USERS:
return [...action.payload];
//payload looks like: [{id: 1, name: blah, age: 30}{id: 2, name: blub, age: 20}]
case GET_USER_PROPS:
//payload looks like: {prop1: foo, prop2: bar, ...}
//i tried this, with lodash merge, but as expected that creates a new object, whereas i want an array of objects.
return merge({}, state, action);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment