---
source: https://iinventedlight.com/library/notes/react-uselayouteffect.md
title: "React useLayoutEffect: an Effect that runs before paint"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (React docs); CC-BY-4.0 (reactjs/react.dev); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: react uselayouteffect"
tags: [react, uselayouteffect, effects, layout, hooks]
client: Librarian
sources:
  - id: S1
    title: "useLayoutEffect"
    publisher: React docs
    url: https://react.dev/reference/react/useLayoutEffect
    accessed: 2026-11-18
    license: "CC-BY-4.0"
  - id: S2
    title: "useLayoutEffect.md"
    publisher: reactjs/react.dev
    url: https://github.com/reactjs/react.dev/blob/main/src/content/reference/react/useLayoutEffect.md
    accessed: 2026-11-18
    license: "CC-BY-4.0"
---
# 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

```jsx
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

- `useLayoutEffect` fires before the browser repaints the screen.
- `cleanup` may be returned from the setup function.
- `undefined` is what useLayoutEffect returns.

## See also

- [react-effects](https://iinventedlight.com/library/notes/react-effects/)
- [react-components-basics](https://iinventedlight.com/library/notes/react-components-basics/)
- [react-refs](https://iinventedlight.com/library/notes/react-refs/)

## 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: "`useLayoutEffect` returns `undefined`"

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
