Question d’entretien chez Freelancer

Explain the difference between useEffect and useLayoutEffect in React, and when would you use one over the other.

Réponse à la question d'entretien

Utilisateur anonyme

25 mars 2026

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.