time elapsed before and after I tested with console.time and console.timeEnd before and after setState
console.time("aaa")
this.setState({
samePageCharts: samePageCharts,
contentData: contentData,
activeIndex: activeIndex,
entityName: data.data.entityName,
haveNextPage: !data.data.samePageCharts.lastPage
})
console.timeEnd("aaa") //aaa: 870.766845703125ms
The console prints 800cm. Why? If it is asynchronous, shouldn"t the time be very short?
after rubbing Zhihu, we found that there are Synchronize updates and asynchronous updates in setState.
the event handling process controlled by React setState will not update this.state.state by Synchronize!
in cases outside the control of React, setState updates this.state.state on Synchronize!
the specific link is here