React useLayoutEffect: an Effect that runs before paint
Answer: useLayoutEffect is a version of useEffect that fires before the browser repaints the screen. The docs warn that useLayoutEffect can hurt performance. The setup function may return a cleanup function, and the hook itself returns undefined.
Examples
useLayoutEffect(() => {
// measure layout here
return () => {};
}, []);
Notes
React runs the cleanup function before the component is removed from the DOM. You cannot call this hook inside loops or conditions. If you omit dependencies, the Effect re-runs after every commit.
Reference list
useLayoutEffectfires before the browser repaints the screen.cleanupmay be returned from the setup function.undefinedis what useLayoutEffect returns.
See also
Claims
- id: C1 claim: useLayoutEffect fires before the browser repaints the screen. source: S1 evidence: "fires before the browser repaints the screen"
- id: C2 claim: useLayoutEffect can hurt performance. source: S1 evidence: "useLayoutEffect can hurt performance"
- id: C3 claim: useLayoutEffect returns undefined. source: S2 evidence: "
useLayoutEffectreturnsundefined"
Sources
- [S1] useLayoutEffect. React docs. https://react.dev/reference/react/useLayoutEffect . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] useLayoutEffect.md. reactjs/react.dev. https://github.com/reactjs/react.dev/blob/main/src/content/reference/react/useLayoutEffect.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, useLayoutEffect; reactjs/react.dev, useLayoutEffect.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, useLayoutEffect; reactjs/react.dev, useLayoutEffect.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates.
Cite this
iinventedlight. 2026. "React useLayoutEffect: an Effect that runs before paint." iinventedlight Library, iil:note:6p6dzmm0, version of 2026-11-18. https://iinventedlight.com/library/notes/react-uselayouteffect/. License: CC-BY-4.0.
@misc{iil_note_6p6dzmm0,
author = {{iinventedlight}},
title = {{React useLayoutEffect: an Effect that runs before paint}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/react-uselayouteffect/},
note = {Permanent ID iil:note:6p6dzmm0. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- react-uselayouteffect.table.json (table; CC-BY-4.0)
- react-uselayouteffect.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-uselayouteffect.md.