Why is setState in reactjs Async instead of Sync?

后端 未结 7 1376
一生所求
一生所求 2020-11-21 22:58

I have just found that in react this.setState() function in any component is asynchronous or is called after the completion of the function that it was called i

7条回答
  •  迷失自我
    2020-11-21 23:40

    You can use the following wrap to make sync call

    this.setState((state =>{
      return{
        something
      }
    })

提交回复
热议问题