Answer
Both run after render, but at different times:
useEffect | useLayoutEffect | |
|---|---|---|
| Timing | After paint (async, non-blocking) | After DOM update, before browser paint |
| Blocks paint | No | Yes — use sparingly |
| Use for | Data fetch, subscriptions, logging | DOM measurement, sync layout, tooltip positioning |
Rule of thumb: start with useEffect; switch to useLayoutEffect only when users see a flash of wrong layout.