Explain the difference between useEffect and useLayoutEffect in React, and when would you use one over the other.
Utilisateur anonyme
explained that useEffect runs asynchronously after the browser paints, making it suitable for data fetching and side effects, while useLayoutEffect runs synchronously before the paint, useful for DOM measurements or animations where you need to avoid visual flicker.