← React Beginner Questions - Set 10 Q96

What is the difference between useEffect and useLayoutEffect?

React Beginner Questions - Set 10

Example

useLayoutEffect(() => { setHeight(ref.current.offsetHeight); }, []);  // before paint
useEffect(() => { fetchData(); }, []);                                // after paint

What to notice

← Back to the question list