"The app feels slow" is a symptom, not a diagnosis. Before sprinkling React.memo and useCallback everywhere and hoping it helps, you need to know precisely which component is re-rendering, how often, and more importantly why React decided to re-render it at all. The React DevTools Profiler gives you that answer; guessing doesn't.

What a re-render actually costs

A re-render isn't automatically a problem. React is quite good at telling "recompute a component's JSX" (cheap) apart from "touch the real DOM" (expensive), thanks to Virtual DOM diffing. The real issue shows up when a component doing heavy work in its body (sorting a large list, transforming data), or sitting at the top of a deep subtree, re-renders for a reason that has nothing to do with the data it's actually displaying.

Finding the culprit with the Profiler

The Profiler tab in React DevTools records a commit every time React applies changes to the DOM, and renders it as a flamegraph: each bar is a component, its width is render time, its color indicates relative cost. Checking "Record why each component rendered" (available in development mode) shows, for any selected component, the exact reason: changed props, changed state, a re-rendered parent, or a changed context value.

// manual instrumentation with the <Profiler> component,
// useful for continuous logging without opening DevTools
import { Profiler, type ProfilerOnRenderCallback } from "react";

const onRenderCallback: ProfilerOnRenderCallback = (
  id, phase, actualDuration, baseDuration
) => {
  if (actualDuration > 16) {
    console.warn(`[${id}] ${phase} took ${actualDuration.toFixed(1)}ms`);
  }
};

export function Dashboard() {
  return (
    <Profiler id="Dashboard" onRender={onRenderCallback}>
      <OrdersTable />
    </Profiler>
  );
}

The 16ms threshold isn't arbitrary: it's the budget available to hold a steady 60 frames per second. A component that regularly blows past that during the update phase is a serious optimization candidate; one that stays under it probably isn't worth the effort, even if it's technically re-rendering "unnecessarily."

Trap number one: a context value that re-renders the whole tree

A Context.Provider whose value is recreated on every render of its parent (an inline object literal, for instance) triggers a re-render of every consumer of that context, even the ones only reading a field that didn't change. It's the most common cause of a cascading re-render across an entire subtree.

// problem: { user, theme } is a brand new object on every AppProvider render
function AppProvider({ children }) {
  const [user, setUser] = useState(null);
  const [theme, setTheme] = useState("light");

  return (
    <AppContext.Provider value={{ user, theme, setUser, setTheme }}>
      {children}
    </AppContext.Provider>
  );
}
// fix: memoize the value, and consider splitting the context into two
// (UserContext / ThemeContext) if their update frequencies differ
function AppProvider({ children }) {
  const [user, setUser] = useState(null);
  const [theme, setTheme] = useState("light");

  const value = useMemo(
    () => ({ user, theme, setUser, setTheme }),
    [user, theme]
  );

  return (
    <AppContext.Provider value={value}>{children}</AppContext.Provider>
  );
}

Splitting the context is often the better fix, not just memoizing the value: if theme changes ten times more often than user, bundling them into one context forces user consumers to re-render on every theme change regardless of memoization, because the reconstructed value changes whenever any field does.

Trap number two: inline props that defeat memoization

React.memo compares props by reference (Object.is by default). An object, array, or function recreated on every parent render has a different reference even when its contents are identical, which makes React.memo entirely inert.

// the memo accomplishes nothing: onSelect is a brand new function every render
function ProductList({ products }) {
  return products.map((p) => (
    <ProductRow
      key={p.id}
      product={p}
      onSelect={() => handleSelect(p.id)}
    />
  ));
}

const ProductRow = React.memo(function ProductRow({ product, onSelect }) {
  // re-renders on every ProductList render despite the memo
  return <div onClick={onSelect}>{product.name}</div>;
});
// fix: stabilize the reference with useCallback, or pass the id
// instead of a closure
const ProductRow = React.memo(function ProductRow({ product, onSelect }) {
  return <div onClick={() => onSelect(product.id)}>{product.name}</div>;
});

function ProductList({ products, onSelect }) {
  // onSelect comes from the parent, stable as long as it's itself
  // memoized with useCallback
  return products.map((p) => (
    <ProductRow key={p.id} product={p} onSelect={onSelect} />
  ));
}

useCallback and useMemo aren't free: they add their own dependency-comparison cost. Applying them reflexively "just in case" on components that are never wrapped in a downstream React.memo adds nothing, since nothing actually benefits from the referential stability gained.

Trap number three: an unstable key that unmounts instead of re-rendering

React uses the key prop to decide whether a list item corresponds to the same logical node across renders, or whether it's a different node to mount and unmount. Using the array index as key on a list whose order can change (sorting, filtering, inserting at the top) fools React: it maps old items to new ones by position rather than by identity, which unmounts and remounts components that should have simply re-rendered with new props, losing their local state in the process (a form field mid-typing, an in-flight transition animation).

// problem: sorting products changes the order, index 0 no longer
// refers to the same product, so React unmounts/remounts instead of re-rendering
{products.map((p, index) => (
  <ProductRow key={index} product={p} />
))}

// fix: a stable key tied to the data's actual identity
{products.map((p) => (
  <ProductRow key={p.id} product={p} />
))}

In the Profiler, this trap has a distinctive signature: the component doesn't show up as "re-rendered" in the usual flamegraph sense, it shows up as unmounted and then fully remounted (a brand new node in the commit tree), which costs considerably more than a plain re-render since React re-runs every mount effect (a dependency-free useEffect, entry animations) instead of simply reconciling props.

Memoizing a computation, not just a component

useMemo serves a different purpose than React.memo: it doesn't prevent a component from re-rendering, it avoids redoing an expensive computation during a render that was going to happen anyway, for an unrelated reason (a UI state change that has nothing to do with the computation, for instance).

function OrdersTable({ orders, sortKey }) {
  // without useMemo, this sort recomputes on every OrdersTable render,
  // including when only an unrelated local UI state changes (opening a tooltip)
  const sorted = useMemo(
    () => [...orders].sort((a, b) => a[sortKey] - b[sortKey]),
    [orders, sortKey]
  );

  return <Table rows={sorted} />;
}

The reverse trap exists too: memoizing a trivial computation (useMemo(() => a + b, [a, b])) costs more than just letting it run, because comparing dependencies isn't free either. useMemo only pays off when the memoized computation is measurably more expensive than that comparison, which is again a question to settle with the Profiler rather than by intuition.

Diagnosing before fixing

The sequence that avoids guesswork: open the Profiler, reproduce the slow interaction, find the component with the highest actualDuration relative to its subtree in the flamegraph, then check the displayed re-render reason for that specific component. If the reason is "props changed" on a prop that, on inspection, has no business reason to change, that's the signature of an unnecessarily recreated prop (an inline object or function) rather than an actual data change.

When manual memoization isn't enough

On a list with several thousand items, even with perfect memoization, the nature of the problem shifts: it's no longer an avoidable re-render, it's an initial render or a scroll that has to put too much real DOM on screen at once. At that point useMemo/React.memo contribute nothing, and the right answer is virtualization (only rendering the rows visible in the viewport, using a library like react-virtual or react-window), which cuts down the number of DOM nodes actually mounted rather than optimizing the Virtual DOM recalculation.

It's also worth noting that the React Compiler (available since React 19) automates part of this memoization at build time by analyzing the source code, which reduces the need for manual useMemo/useCallback in the cases it covers. It doesn't replace the initial diagnosis, though: you still need to identify which component is the problem before deciding whether compiler automation, a manual fix, or a structural solution like virtualization is the right answer.

The Profiler doesn't replace understanding how React's rendering actually works, but it turns "I think this re-renders too much" into a precise measurement and a named cause. Optimizing without that step amounts to handing out memoization at random, with a real risk of making the code more complex without making it any faster.