Is react setState asynchronous? How to use Synchronize setState?

/**
   * output:
   *  click  {page: 2}
   *  click  {page: 3}
   * @memberof index
   */
Feb.15,2022

setState itself is not asynchronous, but for performance optimization, there is no immediate update


get

from the callback of the second parameter.
this.setState({},()=>{
    console.log(this.state.obj);
})

  official documents  

Menu