posted a question on Stack Overflow, but I think it _may_ be a bug in react-redux (or maybe I'm just a dum dum) :)
http://stackoverflow.com/questions/39667805/react-redux-update-item-in-array-doesnt-re-render
You're directly mutating the state by calling push on the array instance. Since the array reference is the same before and after, connect assumes nothing has changed and doesn't re-render. Please see the Redux FAQ on the topic: http://redux.js.org/docs/FAQ.html#react-not-rerendering
Thanks!
keep in mind that having a list within an object it's not enough to use Object.assign an copy the object, also the list needs to be copied separately e.g. using slice()
e.g.
const initialState = {
customers: [],
date: null,
states: ['state1', 'state2']
};
//.... and in reducer:
case SET_STATES:
return {
...state,
states: action.states.slice()
};
Most helpful comment
You're directly mutating the state by calling
pushon the array instance. Since the array reference is the same before and after,connectassumes nothing has changed and doesn't re-render. Please see the Redux FAQ on the topic: http://redux.js.org/docs/FAQ.html#react-not-rerendering