Home / Articles

Eight React Rendering Fixes That Cut Re-renders 80% Without a Rewrite

Profile first, then apply memo, useMemo, useCallback, transitions, list virtualization, code splitting and narrow selectors to speed up a large React dashboard.

Publisher: REACTAPP.TOP5 min read1245 words

This article is published in English.

Sources: How I Optimized a Slow React App Without Rewriting It

Picture a dashboard demo where every filter click freezes the screen for a full second. The code is tidy and follows best practices, and it's still painfully slow. The codebase has 50,000 lines and nobody has budget for a rebuild, so the only option is to make rendering smarter without changing features. The steps below follow that path, and in the example scenario they cut re-renders by about 80%.

Measure before touching anything

Optimizing blind wastes time, so profiling comes first. Three tools do most of the work:

  • The React DevTools Profiler, for recording interactions and reading the flame graph to see which components re-render needlessly.
  • why-did-you-render, a library that logs avoidable re-renders.
  • The Chrome DevTools Performance tab, for real frame times.

The typical pattern is easy to spot. A parent updates its state and every child below re-renders, whether or not it uses the changed data. In a small app that hardly matters. In a dashboard with hundreds of components, one state change at the top can set off a cascade.

Memoize components with React.memo

When a component gets the same props, it should produce the same output, and React.memo caches that output. The sensible approach is to start with the pure components that appear most often in the profiler's re-render list, not to wrap everything.

const ExpensiveComponent = React.memo(({ data, onUpdate }) => {
  // Component logic
});

One catch: React.memo compares props shallowly. A function passed as a prop is recreated on each render, so the memo never hits. useCallback covers that case. Once memoization is applied where it counts, components that once re-rendered on every state change now do so only when their own props change.

A word of caution: not every component benefits. Only those that re-render often with identical props gain anything. Memoizing everything can hurt, because storing previous results costs memory.

useMemo and useCallback

React.memo prevents component re-renders. useMemo and useCallback prevent repeated work inside them.

Take a component that computes aggregate statistics from a large array. If that runs on every render, including renders where the data didn't change, it's wasteful. Wrapping it in useMemo with the data as a dependency means it only reruns when the data does:

const computedStats = useMemo(() => {
  return expensiveAggregation(data);
}, [data]);

useCallback solves a different problem. Event handlers passed to children get a fresh identity on each render, which defeats the shallow comparison inside React.memo. Wrapping the handler keeps its reference stable:

const handleUpdate = useCallback((id) => {
  updateItem(id);
}, []);

The effect is that costly calculations stop repeating, children stop re-rendering for nothing and the interface feels more responsive.

Keep typing responsive with useTransition

A click should get an immediate reaction, but a heavy state update can freeze the browser until it finishes. Consider a search box that filters a list of 10,000 items. Without help, each keystroke blocks the screen for hundreds of milliseconds.

useTransition marks the update as low priority, so React keeps the interface alive while the heavy work proceeds in the background:

const [isPending, startTransition] = useTransition();
const handleSearch = (term) => {
  startTransition(() => {
    setSearchTerm(term);
    // Filtering happens in the background
  });
};

The filtering still happens, just not at the cost of typing. The difference is obvious as soon as someone uses the box.

Delay values with useDeferredValue

useDeferredValue resembles useTransition but applies to a value instead of a state update. It tells React the value may lag when something more urgent is going on.

Imagine a live chart that re-renders whenever data changes. Its rendering is expensive and blocks other updates. Deferring the value it receives lets React paint the urgent parts first:

const deferredData = useDeferredValue(data);
// Chart receives deferredData and updates only when React has idle time

Charts and visualizations then stop blocking interaction, and the app stays smooth with large datasets.

Virtualize long lists

A user sees only a small slice of a list at any moment, so rendering all of it wastes resources. A table with 500 rows, all mounted as DOM nodes on every update, is a good candidate. Replacing a raw map() with react-window, which renders only visible rows, changes that:

import { FixedSizeList } from 'react-window';
const Row = ({ index, style }) => (
  <div style={style}>
    {data[index].name}
  </div>
);
<FixedSizeList
  height={400}
  itemCount={data.length}
  itemSize={35}
  width="100%"
>
  {Row}
</FixedSizeList>

In the example, the table mounted about 20 rows instead of 500. Memory use dropped, scrolling smoothed out and the page loaded faster.

Split the bundle by route

Shipping the whole application on first load is another common mistake. If dashboard, analytics, settings and reports views are all compiled into a single JavaScript file, the first load drags. React's lazy and Suspense split the bundle per route, so each view loads when the user navigates to it:

const Dashboard = lazy(() => import('./views/Dashboard'));
const Analytics = lazy(() => import('./views/Analytics'));
function App() {
  return (
    <Suspense fallback={<Loading />}>
      <Routes>
        <Route path="/" element={<Dashboard />} />
        <Route path="/analytics" element={<Analytics />} />
      </Routes>
    </Suspense>
  );
}

In this scenario the initial bundle fell from 2.5 MB to 800 KB, and first load improved noticeably.

Narrow your state selectors

With Redux or Zustand, components often select more state than they need. If a root component grabs the whole store through useSelector, any change anywhere in the store re-renders it. The cure is to select only the slices each component uses and to memoize derived data with createSelector from Redux Toolkit:

import { createSelector } from '@reduxjs/toolkit';
const selectFilteredData = createSelector(
  (state) => state.items,
  (state) => state.filterTerm,
  (items, term) => items.filter(item =>
    item.name.toLowerCase().includes(term.toLowerCase())
  )
);
// In component:
const filteredData = useSelector(selectFilteredData);

Now components re-render only when data they actually read changes, and the cascade of updates stops.

Before and after

Metric Before After
Average re-renders per interaction 47 9
Time to interactive 2.3 s 1.1 s
Frame drops during animations Frequent Rare

That's roughly 80% fewer re-renders, with the same codebase and the same features.

What this shows

Speeding up a React app is mostly a matter of understanding, not rewriting. The profiler decides where to look, so effort doesn't go to random components. Each change addresses one specific problem and has a measurable effect, and most take half an hour or less. They're surgical improvements, not architectural overhauls.

In short, the toolbox is React.memo for pure components, useMemo for heavy calculations, useCallback for stable handlers, the two concurrent hooks for work that can wait, react-window for long lists, lazy loading for routes and tight selectors for store state.

Applied one at a time and consistently, these patterns turn a slow app into one that feels instant. Start with the DevTools profiler, find the biggest bottleneck and fix it first.