← React Intermediate Questions - Set 10 Q94
What is the difference between `useEffect` and `useLayoutEffect`?
React Intermediate Questions - Set 10
Example
1
2
useLayoutEffect(() => { setW(el.current.offsetWidth); }, []);
useEffect(() => { track('view'); }, []);
What to notice
- Layout variant runs before paint and can cause jank if it does real work.
← Back to the question list