- 1 current stop: learning
- 2 upcoming
- 3 upcoming
- 4 upcoming
- 5 upcoming
Finish after stop 5
Stop 1 of 5 · Last hill: the service station
Trick to keep in mind+3 XP
Ask why it runs: user did something means handler, screen must stay in sync means effect.
An event handler runs in direct response to something the user did, such as a click or a submit. An effect runs because the component is on screen and needs to stay synchronised with something outside React, such as a timer, a subscription or data for the current id. Look at the cause of the code, not at how technical it feels.
Read it once, then a question tests whether the trick stuck.