---
source: https://iinventedlight.com/library/notes/react-usememo.md
title: "useMemo caches a calculation between re-renders and is only a performance optimization"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (React docs (reference)); CC-BY-4.0 (React docs (learn)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
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 useMemo"
tags: [react, useMemo, memoization, hooks, performance]
client: Librarian
sources:
  - id: S1
    title: "useMemo"
    publisher: React docs (reference)
    url: https://react.dev/reference/react/useMemo
    accessed: 2026-11-18
    license: "CC-BY-4.0"
  - id: S2
    title: "You Might Not Need an Effect"
    publisher: React docs (learn)
    url: https://react.dev/learn/you-might-not-need-an-effect
    accessed: 2026-11-18
    license: "CC-BY-4.0"
---
# 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

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

## Rules

- Call it only at the top level of your component or Hooks, never inside loops or conditions.
- In Strict Mode, React calls your calculation function twice to help you find accidental impurities (development-only behavior).
- Rely on `useMemo` only as a performance optimization. If the code doesn't work without it, fix the underlying problem first.

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

- [react-when-not-to-use-effect](https://iinventedlight.com/library/notes/react-when-not-to-use-effect/)
- [react-pure-components](https://iinventedlight.com/library/notes/react-pure-components/)
- [react-state](https://iinventedlight.com/library/notes/react-state/)

## Claims

- id: C1
  claim: useMemo caches a calculation result between re-renders.
  source: S1
  evidence: "lets you cache the result of a calculation between re-renders"

- id: C2
  claim: Dependencies are compared with Object.is.
  source: S1
  evidence: "React will compare each dependency with its previous value using the Object.is comparison"

- id: C3
  claim: useMemo should only be a performance optimization.
  source: S1
  evidence: "You should only rely on useMemo as a performance optimization."

- id: C4
  claim: React Compiler can memoize expensive calculations automatically.
  source: S2
  evidence: "React Compiler can automatically memoize expensive calculations for you"

## Sources

- [S1] useMemo. React docs (reference). https://react.dev/reference/react/useMemo . License: CC-BY-4.0. Accessed 2026-11-18.

- [S2] You Might Not Need an Effect. React docs (learn). https://react.dev/learn/you-might-not-need-an-effect . 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 (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.

---

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