I was updating a certain redux state in reducer like this,
case UPDATE_SOMETHING:
return {
...state,
something: action.something,
};
and i was checking the state update like following,
componentDidUpdate(prevProps, prevState) {
const { something } = this.props;
if (!_.isEqual(prevProps.something, something)) {
this.setState({ something });
}
}
But the problem is, i can see that my redux state is update in redux debugger, but componentDidUpdate is not firing anymore !!!!. After wondering for a while , i tried to update the redux state using shallow copy. Like this,
case UPDATE_SOMETHING:
return {
...state,
something: {
...state.something,
...action.something,
},
};
Its, working now!!!!!!
Top comments (1)
That feeling when you dig it 🙂🤜