I am working on a react js application and doing some basic stuff, it seems the state is not changing when setting a new value. Here it is the code:
pageChange = currentPage => {
const newState = Immutable.merge(this.state,
{
page: currentPage
},
{ deep: true });
this.setState(newState);
console.log(this.state); // the page property remains the same
console.log(newState); // the page property has the new value, the currentPage
this.openPreview();
}
In the code, the current state is not being set, but newState has the new value. Why?