I don't understand how shouldComponentUpdate() method has access to old state, As i know, shouldComponentUpdate() is fired after props or state changes.
Suppose you call setState() , After that the current state will be changed and will be update with new state. But shouldComponentUpdate() is fired even after updating the state to the latest version. Therefore how can 'this.state' inside shouldComponentUpdate() return the old state?
shouldComponentUpdate(nextProps, nextState) {
console.log(this.state); // how can this be old state?
}
Did anyone get an idea? Thanks a lot.