useEffect
useEffect runs code after the component has rendered. Use it for things outside React, such as timers, subscriptions, or changing the page title. The second argument is a list of dependencies: the effect re-runs only when one of them changes.
Examplereact
setSeconds((s) => s + 1) uses the latest value. The returned function is cleanup: without it the timer would keep running after the component is removed.
Quick check
What does an empty dependency array `[]` mean?
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.