React.memo
A React function that wraps a component so it skips re-rendering when its props are shallowly equal to the previous ones.
In more detail
It only helps if the props really stay the same: an inline object or function prop is new every render and defeats it, so pair it with useMemo and useCallback. A memoized component still re-renders when its own state or a context it reads changes.
Example
const Child = memo(function Child({ onRun }) { ... });Related terms
- shallow comparison — Comparing two objects one property at a time with Object.is, without looking inside nested objects.
- 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.
- memoization — Remembering the result of a calculation for given inputs and reusing it when the same inputs come again, instead of recalculating.
Taught in
- 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