Asynchronous tasks inside React.useEffect can create Stale Closure BUGS!

Veröffentlicht am: 28 September 2020
auf dem Kanal: Joel Codes
2,752
164

Stale closures can catch you off guard when using React.useEffect. In this video I will demonstrate what the bugs are, explain why they happen and also provide solutions to how to solve them.

Be Cautious of React.useEffect Race Condition Bugs:
   • Be Cautious of React.useEffect Race Condit...  

Subscribe to my mailing list: https://joel.net

Twitter:   / joelnet  
Dev.to: https://dev.to/joelnet
Medium:   / joelthoms  

0:20 Thanks to New Subscribers
0:40 What is a State Closure Bug?
1:05 What does this code do?
1:45 Why does this Stale Closure Bug happen?
2:10 Recommended way to set the State
2:40 Conditionally updating values
3:39 Add variables as a dependency to React.useEffect
4:09 The SOLUTION is to use useRef
6:03 Recap of the solution
6:56 Some quick TIPS
7:37 SUBSCRIBE!
7:49 Dumpling!!!


Auf dieser Seite können Sie das Online-Video Asynchronous tasks inside React.useEffect can create Stale Closure BUGS! mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Joel Codes 28 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,752 Mal angesehen und es wurde von 164 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!