Reputation: 8118
I have an array of elements which was updated inside an action, now I want to update it in the store. Currently I have something like:
navigation
|_navigationItems:[{1:"foo"}, {2:"bar"}, {3:"foobar"}]
The thing is I was doing the following:
case types.UPDATE_NAVIGATION:
return Object.assign({}, state, {
navigationItems: action.payload.items,
});
where items is: [{1:"zoo"}, {2:"foobar"}]
but store was not updated succesfully.
Did I miss something?
Upvotes: 1
Views: 472
Reputation: 282040
React docs suggest on using the spread operator syntax over Object.assign
Use:
case types.UPDATE_NAVIGATION:
return {
...state, navigationItems: action.payload.items
}
Upvotes: 1