← All notes

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

See also

Claims

Sources

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

Permanent ID: iil:note:6p6dzmm0

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.},
}

Markdown

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.

All artifact files (JSON index)

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.