React may batch multiple setState() calls into a single update for performance. Because props and state may be updated asynchronously, you should not rely on their values for calculating the next state. code example
Example: setstate react js
constructor(props) {
super(props);
this.state = {
isActive: true,
};
}
checkStatus = () => {
this.setState({ // use this function
'isActive' : !this.state.isActive,
});
}