React · Middle · Question 10 of 75
How does useLayoutEffect differ from useEffect?
- ✓Correct answer: It runs after DOM changes but before painting
- 2It runs only on the server during SSR
- 3It runs before render to prepare data
Explanation
useLayoutEffect blocks painting, so it suits measuring the DOM and adjusting position (tooltips) without flicker. useEffect runs after painting and doesn't block it - it's the default choice. useLayoutEffect doesn't run on the server.