memoization
Remembering the result of a calculation for given inputs and reusing it when the same inputs come again, instead of recalculating.
In more detail
It trades memory for speed and is only correct for pure calculations. Inputs are usually compared by identity to decide whether a stored result applies.
Example
React offers React.memo, useMemo and useCallback, and the React Compiler can add memoization automatically at build time.Related terms
- Request Memoization — The first Next.js caching tier: identical fetch calls made while rendering one request are run only once.
- React cache — A React function that wraps another function so repeated calls with the same arguments during one server request reuse the first result.
- deduplication — Detecting and discarding repeated copies of the same message or request, usually by remembering identifiers already processed.
- React.memo — A React function that wraps a component so it skips re-rendering when its props are shallowly equal to the previous ones.
- useMemo — The React hook that caches the result of a calculation between renders and recalculates only when its dependencies change.
- useCallback — The React hook that returns the same function object between renders until one of its dependencies changes.
- React Compiler — A build-time tool from the React team that automatically adds memoization to components and hooks, so you rarely need useMemo, useCallback or React.memo.
Taught in
- Request Memoization: Automatic Deduplication Tiers — Next.js 15 & Modern App Router Architecture
- Data Cache: Cross-Request Persistence & Fetch Tags — Next.js 15 & Modern App Router Architecture
- Metadata API: Dynamic OpenGraph & Head Management — Next.js 15 & Modern App Router Architecture
- Component Purity: Pure Functions, Idempotence And Side Effects — React 19 & Modern Component Architecture
- Complex State with useReducer: State Machines And Action Types — React 19 & Modern Component Architecture
- Lifting State Up: Colocation, Ownership, And Data Flow — React 19 & Modern Component Architecture
- useContext in Depth: Scoping, Consumer Subscription Costs — React 19 & Modern Component Architecture
- Custom Hook Composition: Encapsulating Reactive Logic — React 19 & Modern Component Architecture
- Render Diagnostics: Profiling Re-Renders with React DevTools — React 19 & Modern Component Architecture
- React.memo, useMemo, And useCallback: Optimization Costs — React 19 & Modern Component Architecture
- The React Compiler: Automated Memoization Under The Hood — React 19 & Modern Component Architecture