What is the useLayoutEffect hook and how does it differ from useEffect?

React Developer Medium

React Developer — Medium

What is the useLayoutEffect hook and how does it differ from useEffect?

Key points

  • useLayoutEffect runs synchronously after DOM mutations
  • useEffect runs asynchronously after the browser paints
  • useLayoutEffect is ideal for immediate layout effects

Ready to go further?

Related questions