Quantcast
Viewing latest article 1
Browse Latest Browse All 3

Answer by satya164 for Why does async work in ComponentDidMount lead to visual lag when navigating unless a simple timeOut is awaited?

Seems like your NetworkRequest.getData(payload) function is doing something expensive synchronously. Because JavaScript is single threaded, the next action doesn't happen until this function returns which can cause a lag.

By adding await timeOut(0), you no longer make it synchronous. It's now called in the next event loop which means any synchronous actions before that would finish already.


Viewing latest article 1
Browse Latest Browse All 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>