← All notes

useMemo caches a calculation between re-renders and is only a performance optimization

Answer: useMemo(calculateValue, dependencies) is a React Hook to cache the result of a calculation between re-renders. React compares each dependency with its previous value using Object.is and reuses the cached value if none changed.

Example

import { useMemo } from 'react';
function TodoList({ todos, filter }) {
  const visibleTodos = useMemo(() => filterTodos(todos, filter), [todos, filter]);
  return <List items={visibleTodos} />;
}

Rules

When it pays off

Optimizing with useMemo is only valuable in a few cases: the calculation is noticeably slow and its dependencies rarely change, or you pass the value as a prop to a component wrapped in memo. If most interactions are granular, like moving shapes in a drawing editor, memoization can be very helpful.

Compiler note

In many cases React Compiler can automatically memoize expensive calculations, so manual useMemo is not needed. You can cache (or "memoize") an expensive calculation by wrapping it in a useMemo Hook.

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 (reference), useMemo; React docs (learn), You Might Not Need an Effect. 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 (reference), useMemo; React docs (learn), You Might Not Need an Effect. 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:sj3g1mj5

iinventedlight. 2026. "useMemo caches a calculation between re-renders and is only a performance optimization." iinventedlight Library, iil:note:sj3g1mj5, version of 2026-11-18. https://iinventedlight.com/library/notes/react-usememo/. License: CC-BY-4.0.

@misc{iil_note_sj3g1mj5,
  author = {{iinventedlight}},
  title = {{useMemo caches a calculation between re-renders and is only a performance optimization}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/react-usememo/},
  note = {Permanent ID iil:note:sj3g1mj5. 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).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-usememo.md.