Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

React.memo can help React skip rendering a functional component when its props have not changed. It is an optimization—not a guarantee, and not a fix for incorrect rendering. Profile a real interaction first, then consider memoizing a component that repeatedly receives the same props and does enough work for skipped renders to matter. If React Compiler is enabled, it usually handles this optimization automatically.

What React.memo does—and what it does not do

memo(Component, arePropsEqual?) returns a memoized component. When its parent renders again, React will usually skip rendering that child if its props are unchanged. By default, React compares each prop using Object.is.

This only addresses parent-driven renders when props remain equal. The component can still render when its own state changes or when a context it uses changes. Memoization is also not a correctness guarantee: React’s documentation says to rely on memo only as a performance optimization, and to fix underlying problems if the code does not work without it. See React’s memo reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When is React.memo worth adding?

Consider it when a component renders often with the same props, its render work is meaningfully expensive, and avoiding those renders improves a real interaction. If you do not notice lag, React says memoization is unnecessary. Use the Profiler in React Developer Tools to identify which components are worth investigating rather than memoizing broadly.

Before adding it, check whether React Compiler is enabled in your project. When it is, the compiler typically optimizes component rendering automatically, so manual React.memo is usually unnecessary. See React Compiler’s introduction.

How to memoize a functional component

Import memo, wrap the component, and use the returned component in place of the original:

import { memo } from 'react';

const Profile = memo(function Profile({ name, age }) {
  return <section>{name}: {age}</section>;
});

export default Profile;

This pattern helps only when the props can remain equal across parent renders and skipping the child’s rendering work is useful. A component whose props change on every render, or whose render is already inexpensive, may gain little from it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why an object, array, or function prop can still trigger a render

“My component re-renders when a prop is an object, array, or function.” A newly created object, array, or function has a different identity from the one created on the previous render. Because memo compares props with Object.is by default, the new reference counts as a changed prop even when the value looks equivalent.

Pass only the values the child needs

If the child uses only a few fields, pass those fields as separate props instead of passing a larger object. Smaller, simpler props are easier to keep stable and compare.

Stabilize a necessary object or callback selectively

If the child needs an object prop, useMemo can preserve its reference until its dependencies change. For a callback, define it outside the component when possible; when it depends on values in the parent, useCallback can preserve its identity while those dependencies remain unchanged. Use these hooks only when stable identity supports an actual optimization, not as routine decoration. See React’s useMemo reference and React’s useCallback reference.

Should you provide a custom prop comparator?

The optional arePropsEqual function is a rare escape hatch, not a default way to make memoization work. Before using one, establish that the default comparison is a performance bottleneck. The comparator must account for every prop, including functions, and return true only when the new props would produce the same behavior as the old ones.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ignoring a changed callback can leave the child using a stale closure—an earlier function that captures outdated parent values. A deep comparison can also cost more than rendering the component. Measure the comparator and rendering cost in production mode, and avoid comparisons whose work can grow without a practical bound. React documents these cautions in its memo reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fix unnecessary updates before optimizing renders

React.memo will not fix visual glitches, side effects, or incorrect output. Keep rendering logic pure, and address unnecessary effect-driven updates first. Keeping transient state local rather than lifting it higher than necessary can also reduce how many components are affected by an update. Add memoization only after the underlying component behavior is sound.

A practical decision checklist

  • React Compiler is enabled: start with its automatic optimization rather than adding manual memoization by default.
  • The component receives the same props frequently and profiling shows meaningful render cost: try memo, then profile the interaction again.
  • A prop is newly allocated each render: first consider passing only the values the child needs; stabilize a necessary object or callback only if that helps the measured case.
  • There is no noticeable performance problem: leave the component un-memoized.
  • You are considering a custom comparator: confirm the default comparison is a bottleneck, check every prop, and measure comparator cost in production mode.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.