Skip to content
← All posts

Dec 4, 2026

Your whole dashboard re-renders on every keystroke — and it's not React's fault

Type one character in a dashboard search box and the whole page re-renders — the chart, the table, the sidebar. React re-renders children whenever their parent re-renders, unless you tell it not to. The fix is putting state where it's used, not at the top of the tree, and reaching for memo only where you can measure that it helps.

ReactTypeScriptPerformance

Type one character in a dashboard search box and watch what happens. The input updates, obviously. But so does everything else — the chart re-runs its calculations, the table re-renders its rows, the sidebar rebuilds its navigation. Type a whole word and the page has done that work ten times, for ten keystrokes, while the user only needed one thing to change: the text in the box.

Nothing is broken. React is doing exactly what it is designed to do. When a component's state changes, the component re-renders — and every child it renders re-renders too, by default, whether or not their props changed. The search box's state lives at the top of the page, so every keystroke re-renders the page. That is the whole bug, and it is in the structure, not in the library.

The rule in one paragraph

A component re-renders when its own state changes, when its props change, when its parent re-renders, or when a context it reads changes. The third one is the one that catches people: a parent re-render cascades down the tree it renders. React still diffs the result and only touches the DOM where something actually changed — the screen doesn't flicker — but running every component function, rebuilding every element, and diffing the whole tree on each keystroke is real work, and on a dashboard with a heavy chart and a thousand-row table it is work the user can feel.

The shape of the bug is a page component that holds all of its state:

function DashboardPage() {
  const [search, setSearch] = useState("");
  const [rows, setRows] = useState<Row[]>([]);
  // ...fetch rows, build chart data...

  return (
    <div>
      <SearchBox value={search} onChange={setSearch} />
      <SalesChart data={chartData} />   {/* re-runs on every keystroke */}
      <OrdersTable rows={rows} />       {/* re-renders on every keystroke */}
      <Sidebar />                       {/* re-renders on every keystroke */}
    </div>
  );
}

search belongs to the search box. Nothing else reads it. But it lives in DashboardPage, so every keystroke re-renders the page, and the page re-renders everything it renders. The chart, the table, the sidebar — none of them needed to move, and all of them did.

Move the state down

The fix that matters most is not a hook. It is moving the state to the component that actually uses it:

function DashboardPage() {
  const [rows, setRows] = useState<Row[]>([]);
  // ...fetch rows, build chart data...

  return (
    <div>
      <SearchBox />          {/* search state lives inside, here */}
      <SalesChart data={chartData} />
      <OrdersTable rows={rows} />
      <Sidebar />
    </div>
  );
}

Now typing updates SearchBox only. The update starts at the component whose state changed, and the parent never re-renders — so the chart and the table are never even considered. This is called state colocation, and it is the cheapest performance fix in React: no memo, no hook, no API, just putting the state where it is used.

The same idea works one level up. If the search box and the table both need the query, the state belongs in their nearest common parent — a SearchSection that wraps only the two of them, not the whole page. State should live as low as it can while still reaching everything that needs it. Every level higher is a level of the tree that re-renders on every change.

There is a second version of the same fix, for a different shape: pass the expensive part as children. Elements passed as children come from the parent that created them, so when the wrapper re-renders, React skips re-rendering those children — they are the same elements as last time:

function SearchPanel({ children }: { children: React.ReactNode }) {
  const [search, setSearch] = useState("");
  return (
    <div>
      <input value={search} onChange={(e) => setSearch(e.target.value)} />
      {children} {/* created by the parent — skipped on re-render */}
    </div>
  );
}

The wrapper owns the fast-changing state, the heavy content rides along untouched. It is the same principle — keep the thing that changes away from the thing that is expensive — expressed as composition instead of colocation.

memo — and why it often does nothing

When the state genuinely has to live high up — a filter in the header that the table below needs — the next tool is React.memo. It tells React to skip re-rendering a component when its props are unchanged. The catch is in the word "unchanged": memo compares props shallowly, with Object.is. Primitives compare by value. Objects, arrays, and functions compare by reference — a new reference means "changed", even if the contents are identical.

And a parent that re-renders creates new references for everything it defines inline:

// Looks optimized. Does nothing.
const OrdersTable = memo(function OrdersTable({ rows, onSelect }) {
  return <table>{/* ... */}</table>;
});

function DashboardPage() {
  const [search, setSearch] = useState("");
  const handleSelect = (id: string) => setSelectedId(id); // new function every render
  return <OrdersTable rows={rows} onSelect={handleSelect} />;
}

Every keystroke re-renders the page, which creates a new handleSelect, which fails the shallow comparison, which re-renders the memoised table anyway. The memo check itself still runs, so this version costs slightly more than not memoising at all. memo only works as part of a system: stable props in, memoised component out. Stabilise the function with useCallback — same reference until its dependencies change — and the object with useMemo:

const handleSelect = useCallback((id: string) => {
  setSelectedId(id);
}, []); // closes over nothing that changes

const visibleRows = useMemo(
  () => rows.filter((r) => r.status === filter),
  [rows, filter],
);

useMemo and useCallback do not make a calculation or a function faster. Their only job is producing a stable reference, so something downstream — memo, or a dependency array in another hook — can correctly tell that nothing changed. Memoising a cheap string concatenation buys nothing; memoising the filtered list you hand to a memoised table buys the whole point of the table's memo.

Measure it before you memoise

None of this is worth doing on instinct. A re-render that costs a fraction of a millisecond is free in practice, and memo has its own cost — the comparison runs on every render, and a tree wrapped in memo everywhere is harder to read and harder to debug. The React DevTools Profiler exists for exactly this: record a keystroke, look at the flamegraph, and see which components actually re-rendered and how long each one took. The components that re-render without their props changing are the optimisation targets. Everything else is a guess.

A useful rule of thumb, from the React docs' own framing: reach for memo when a component is slow to render and re-renders often with the same props; reach for useMemo when a calculation is noticeably slow — the docs suggest around a millisecond, measured in a production build — and its inputs rarely change. If the profiler says the chart costs 0.2ms per keystroke, leave it alone. If it says 40ms, move the state or memoise it.

One more thing the profiler will show you: context. A component that reads a context re-renders whenever that context's value changes, memo or not. If the value is an object literal created in the provider — { user, theme, setTheme } rebuilt on every render — every consumer re-renders on every render of the provider. Stabilise the value with useMemo, or split the context so fast-changing values and slow-changing values live in separate providers. The same reference-equality rule, one level removed.

The honest limits

Re-renders are not free, but they are also not the enemy. React re-rendering a component does not mean touching the DOM — the diff usually finds nothing to change. Most pages are fast enough that a full re-render per keystroke is invisible, and the first version of a page should be written for clarity, not for the profiler. Memoisation is a cache, and React may drop it: useMemo and useCallback are not guarantees, and if correctness depends on a value being computed once, it belongs in state or a ref, not a memo. And if you are on React 19, the React Compiler can insert this memoisation for you — which is a reason to write the straightforward version and let the compiler earn its keep, not a reason to memoise everything by hand.

The dashboard that re-renders on every keystroke is not slow because React is slow. It is slow because the state that changes ten times a second lives at the top of a tree that takes real work to rebuild. Move the state down to where it is used, and the keystrokes stop costing the whole page. Only then — measured, and only where the profiler says it matters — add memo, with stable props, to the parts that are still expensive.