Quick Answer
useLayoutEffect runs synchronously after DOM mutations but before the browser paints. React batches all useLayoutEffect callbacks and runs them together after the commit. Because this happens in the same synchronous execution context as the DOM write, the browser doesn't get a chance to paint between the write and the layout measurement รขโฌโ no thrash.
Answer
React batches DOM reads/writes into phases to avoid bouncing layout calculations.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.