React·100 questions

What is the difference between useEffect and useLayoutEffect?

Answer
useEffect runs after the browser paints.
useLayoutEffect runs synchronously after DOM mutations, before painting.
useLayoutEffect can block rendering.
Use it for measurements/UI flickering.
In most cases, useEffect is sufficient.
Was this answer helpful?

More questions in this topic

Related questions from other topics