← All notes

Keeping React components pure

Pure functions only perform a calculation and nothing more. [S1]

Purity rules

Given the same inputs, a pure function should always return the same result. [S1]

A pure function does not change any objects or variables that existed before it was called. [S1]

React rendering expects component functions to behave like pure functions with respect to their props and state. [S1]

State as a snapshot

However, state behaves more like a snapshot. [S2]

Setting state requests a re-render; the event handler sees the state from the render that created it. [S2]

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs (react.dev), Keeping Components Pure – React, CC BY 4.0 (reactjs/react.dev LICENSE-DOCS); React docs (react.dev), State as a Snapshot – React, CC BY 4.0 (reactjs/react.dev LICENSE-DOCS).

Cite this

Permanent ID: iil:note:fp1xt1ry

iinventedlight. 2026. "Keeping React components pure." iinventedlight Library, iil:note:fp1xt1ry, version of 2026-11-06. https://iinventedlight.com/library/notes/react-pure-components/. License: CC-BY-4.0.

@misc{iil_note_fp1xt1ry,
  author = {{iinventedlight}},
  title = {{Keeping React components pure}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-06},
  url = {https://iinventedlight.com/library/notes/react-pure-components/},
  note = {Permanent ID iil:note:fp1xt1ry. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/react-pure-components.md.