setState() takes time to change the value, and your javascript is asynchronous , and therefore your console.log() will be executed before setState changes the values ββand therefore you will see the result.
To solve this problem, register the value in the callback function of setState as
setTimeout(() => {this.setState({dealersOverallTotal: total}, function(){ console.log(this.state.dealersOverallTotal, 'dealersOverallTotal1'); }); }, 10)
source share