React, the Mental Model

Lesson 2 · atom React, the Mental Model

State & Re-rendering

Update state correctly and know what triggers a render.

Before you start

useState gives you a value and a setter. Calling the setter schedules a re-render; it does not change the variable you're currently looking at. That single fact explains most 'my state is one step behind' confusion.

5 exercises·up to 72 XP·5/5 hearts