Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Prevent Unnecessary Child Component Renders in React

Use React memo to skip some parent-triggered child renders when props stay the same. Learn how changing references, state, context, and React Compiler affect the result.

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.

To skip a child component’s render when its parent updates, wrap the child in memo and make sure its props are unchanged. If a parent creates a new function, object, or array on each render, that new reference can defeat the memoization; use useCallback or useMemo only when profiling shows the work is worth optimizing. Memoization does not stop updates caused by the child’s own state or by context it reads.

First check whether the render is a problem

A render is not automatically a performance defect. Start by reproducing the slow interaction and inspecting component work with React Developer Tools. Optimize when profiling identifies expensive work or a noticeable delay, rather than adding memoization to every component. React describes memo, useMemo, and useCallback as performance optimizations, not correctness requirements: React memo, React useMemo, and React useCallback.

As an Amazon Associate I earn from qualifying purchases.

Use memo for a child with unchanged props

memo returns a memoized component. When its parent renders, React will usually skip rendering that child if each prop is equal to its previous value. By default, React compares each prop with Object.is. This is not a guarantee that the component will never render; it is a way to avoid some parent-driven renders when the inputs have not changed. See the React memo reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { memo } from 'react';

const Results = memo(function Results({ items, onSelect }) {
  return items.map(item => (
    <button key={item.id} onClick={() => onSelect(item)}>
      {item.name}
    </button>
  ));
});

This boundary can help when Results is costly to render and receives the same items and onSelect references across an unrelated parent update. If either prop changes, React has a reason to render the child again.

Keep function and value props stable when needed

Objects, arrays, and functions are compared by identity, not by whether their contents or behavior look equivalent. An inline callback or object literal creates a new reference each time its parent renders, so a memoized child sees a changed prop.

Cache a callback with useCallback

useCallback reuses a function reference until one of its dependencies changes. Include every reactive value the callback uses in its dependency list; leaving one out to preserve the cache can make the callback use stale values. Read the React useCallback reference for the dependency rules.

const handleSelect = useCallback(item => {
  console.log('Selected', item.id);
}, []);

Cache a calculated value with useMemo

useMemo reuses a calculated value while its dependencies remain equal. It is useful here when the value passed to a memoized child would otherwise be freshly created on every parent render, or when the calculation itself is costly. Include all reactive inputs in the dependency list. See the React useMemo reference.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const visibleItems = useMemo(
  () => items.filter(item =>
    item.name.toLowerCase().includes(query.toLowerCase())
  ),
  [items, query]
);

Put the pieces together

import { memo, useCallback, useMemo, useState } from 'react';

const Results = memo(function Results({ items, onSelect }) {
  return items.map(item => (
    <button key={item.id} onClick={() => onSelect(item)}>
      {item.name}
    </button>
  ));
});

function SearchPage({ items }) {
  const [query, setQuery] = useState('');
  const visibleItems = useMemo(
    () => items.filter(item =>
      item.name.toLowerCase().includes(query.toLowerCase())
    ),
    [items, query]
  );
  const handleSelect = useCallback(item => {
    console.log('Selected', item.id);
  }, []);

  return (
    <>
      <input value={query} onChange={event => setQuery(event.target.value)} />
      <Results items={visibleItems} onSelect={handleSelect} />
    </>
  );
}

When query changes, the filtered results change, so Results should render to show the new list. The memoization is relevant to unrelated parent updates when both child props remain stable; this example is an explanatory pattern, not a measured performance result.

Know which updates memoization cannot stop

The child’s own state changes

memo does not prevent a component from rendering when its own state changes. It only helps with some renders caused by its parent.

Context read by the child changes

A component that reads context still updates when that context value changes, even if it is wrapped in memo. Context consumers respond to provider value changes; memoization does not shield them. One option is to read context in an outer component and pass only the needed value to a memoized inner component. See the React useContext reference and the memo reference.

A dependency changes

useCallback and useMemo refresh their cached result when a listed dependency changes under Object.is. That is expected: if an input changes, a derived value or callback may need to change too. Do not omit reactive dependencies solely to make a reference appear stable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fix the source of excess work before adding more caches

  • Reduce unnecessary state propagation: keep transient state close to the component that uses it, so unrelated parts of the tree do not need to respond to it.
  • Use composition where it fits: a visual wrapper can accept JSX as children, allowing the wrapper’s own state changes without unnecessarily recreating the wrapped content.
  • Remove avoidable update chains: reconsider Effects that set state when the same result can be derived during rendering or managed more directly.
  • Simplify changing props: if a memoized child receives an always-new object or array, consider passing simpler props or stabilizing the value when profiling supports the change.

These structural approaches can be clearer than accumulating memoization. React’s guidance on useCallback and useMemo cautions that most calls provide no benefit unless they support a memoized child, a Hook dependency, or a slow calculation. A single always-new value can also defeat a memo boundary.

Check whether React Compiler is active

React Compiler can automatically handle many memoization cases when it is installed, configured, and compiling the component. Do not assume it is enabled just because a project uses React; confirm the project’s compiler setup and scope in the React Compiler documentation. Whether manual memoization is useful depends on that setup and on the actual render cost.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.