How React's setState is evaluated | 2023 React Interview Questions and Answers

Veröffentlicht am: 17 August 2023
auf dem Kanal: UI Engineering
3,996
342

If you are preparing for 2023 React Interview, it might be worth to go deep into the execution of setState() function. Why setState is not updating immediately? Why we should use callback setter function in setState? Why using 2 setState in the row is not the best idea? setState asynchronicity is an important idea in React, and I'll try to do my best to help you understand how it really works.

⏱️Timestamps:
00:00 - Introduction
00:23 - Most common problem with setState
00:38 - Analyzing initial problem as JS Engine
01:04 - Breaking React's Rule
01:27 - React Component vs React Element
01:42 - Analyzing direct variable assignment
02:28 - First React's Execution Rule
03:37 - Functions of setState()
03:58 - setState() and direct assignment comparison
04:40 - Second React's Execution Rule
04:59 - Virtual Queue metaphor
05:57 - Analyzing callback execution (the fix)
07:29 - Third React's Execution Rule


Auf dieser Seite können Sie das Online-Video How React's setState is evaluated | 2023 React Interview Questions and Answers mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer UI Engineering 17 August 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,996 Mal angesehen und es wurde von 342 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!