Is setState really executed asynchronously?

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

Mar.09,2021

my understanding is that setState does not guarantee Synchronize, that is, sometimes it is asynchronous, sometimes it is Synchronize. It seems that most of the code triggered by user actions is Synchronize.


must be asynchronous.
want Synchronize to execute:

setState({/*..*/}, () => {/* then do something */})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea163e-465d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea163e-465d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?