When updating state of the component the corresponding method from lifecycle get called but every time for any component the prevState or nextState is in fact always the same with the current state. So comparing them always return true. Mentioned methods should return correct objects for previous, next state.
getInitialState: function () {
return {
test: false
};
}
someMethod: function () {
this.setState({
test: true
});
}
componentDidUpdate: function (prevProps, prevState) {
console.log(prevState.test === this.state.test); // Always true!
},
When updating state of the component the corresponding method from lifecycle get called but every time for any component the
prevStateornextStateis in fact always the same with the current state. So comparing them always return true. Mentioned methods should return correct objects for previous, next state.