MemotivaProps and State

Why should setState calls be treated as asynchronous?

Props and State

Audio flashcard · 0:12

Nortren·

Why should setState calls be treated as asynchronous?

0:12

State setters in React do not update the state immediately; they schedule an update. Reading state right after calling the setter returns the old value. If the next state depends on the previous one, you should pass a function to the setter.