score:1

Accepted answer

setstate is asynchronous, refer https://medium.learnreact.com/setstate-is-asynchronous-52ead919a3f0.

setstate enables you to make a callback function after you set the state so you can get the real state. in your case

this.setstate({id: value}, () => console.log(this.state.id));

Related Query

More Query from same tag