Chapter 03
Effects
Effects synchronize a component with something outside React. This chapter covers when they run, how dependencies decide re-runs, cleanup, the layout variants, when an effect is the wrong tool, and Effect Events.- 010When does
useEffectrun, and what is it for?Coremedium - 020How do effect dependencies work, and how do you fix a stale closure?Corehard
- 030Why does an effect run twice in development, and how should cleanup work?Coremedium
- 040When do you need
useLayoutEffectinstead ofuseEffect?medium - 050Which effects shouldn't be effects?Coremedium
- 060What problem does
useEffectEventsolve?hard