I thought assign
was supposed to make a new object, that's why I did this in my reducer:
case types.ADD_ATTRIBUTE:
var newState = Object.assign({}, state)
newState.attributes[action.industry].push(action.attribute)
return Object.assign({}, state, newState);
case types.REMOVE_ATTRIBUTE:
var newState = Object.assign({}, state)
var removeIndex = newState.attributes[action.industry].indexOf(action.attribute)
newState.attributes[action.industry].splice(removeIndex, 1)
return Object.assign({}, state, newState);
However, when I do this, the component will not trigger an update (componentWillReceiveProps
). It does receive the new props, but the react-redux
internal shouldComponentUpdate
does not detect changes.
What am I doing wrong here?