useEffect
useEffect runs after paint. Use it for fetching, subscriptions, and timers. Return a cleanup function when you subscribe.
- Dependency array controls when the effect re-runs.
- [] means run once on mount.
- Do not ignore exhaustive-deps warnings blindly.
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.