Rendering 20,000 rows in React without freezing the page
A reproducible React virtualization benchmark with 20,000 synthetic rows, raw runs, median filter delays, fixed-height windowing code and measurement limits.
By M. Adnan Saleem · · Updated · 11 min read
On a multi-currency payments platform I optimized large data tables with react-window virtualization and memoization, which cut render time by about 70% on datasets over 20,000 rows. That is a historical client result. The synthetic benchmark below is a separate reproduction of the windowing technique, using the hand-written live demo at the end of this article; it does not recreate the client application or validate that percentage.
Reproducible React virtualization benchmark: 20,000 rows
On 15 October 2026 I tested the same two filter actions with windowing off and on in a local production build. The demo generates 20,000 synthetic transfers from seed 42; exactly 2,361 match EUR. Each row has four cells, a fixed height of 36px, a 432px scroll area and six overscan rows on each side. At scroll position zero, windowing mounts 18 rows. This implementation uses useMemo for filtering, but no memoized row component and no react-window dependency.
| Same filter action | Windowing off | Windowing on |
|---|---|---|
| Blank → EUR | 432 (368–618) | 11 (10–14) |
| EUR → blank | 793.5 (704–2570) | 11.5 (9–15) |
After filtering, the non-windowed DOM contains 2,361 rows; clearing it restores 20,000. The windowed DOM holds 18 in both cases at the top of the list. Filtering still scans the same data in either mode. The difference here is how much of the result React and the browser have to update.
Test environment: Apple M5, 16 GiB RAM, macOS 27.0.1, Codex in-app browser reporting Chromium 155, React/React DOM 19.2.3 and Next.js 16.3.5. The visible viewport was 1280 × 720 CSS pixels at device pixel ratio 2. No CPU or network throttling was applied by the test. Other desktop work was running and the display refresh rate was not recorded, so these absolute timings are specific to this session.
Repeat the benchmark
Start with the exact measured demo source at commit a0ef1bb. The raw JSON records all 64 official samples, environment, source checksum and summaries, including warmups.
git clone https://github.com/theadnansaleem/adnan-portfolio.git
cd adnan-portfolio
git checkout a0ef1bb8dca1a905a2174cef91435fe4345a41b5
npm ci
npm run build
npm run start -- --hostname 127.0.0.1 --port 3047- Open
http://127.0.0.1:3047/labin a visible browser tab. Use the same viewport for both modes, pause the simulated threat feed, leave the transfer table scrolled to the top, and start with a blank filter. - Replace the whole filter with
EURin one action, then clear it in one action. Wait for the timer to update after each action and record the displayed estimate and row count. Typing E, U and R separately is a different test. - Use four blocks in this order: windowing off, on, on, off. In each block, discard three filter/clear warmup pairs, then record five pairs. This gives ten measured runs for each action in each mode. Do not include the mode-toggle timings.
- Keep the two actions separate. Sort each group of ten timings and average its fifth and sixth values for the median; also report the minimum and maximum. Retain every measured sample, including slow outliers.
For the recorded run, browser automation changed the whole input value, captured a screenshot after each action, then read the timer and row count. That observation can add overhead. Preliminary pilots were excluded when full-DOM accessibility snapshots exceeded the browser message limit; all official samples used the same screenshot procedure. No official measured sample was removed. The timings exclude page load and network transfer, and do not measure scroll smoothness, memory, INP or a general React speedup.

A compressed performance trace captures a separate non-windowed filter/clear pair with devtools.timeline and blink.user_timing categories. It is excluded from the table because tracing adds overhead. Load it in the Chrome DevTools Performance panel to inspect scripting, layout and paint activity; Chrome documents saving and loading traces. Record your own trace with windowing on for comparison.
See my React experience or read the payments-platform case study for the production context behind this example.
Why a big table is slow
The data is rarely the problem. Twenty thousand objects in memory is nothing. The cost is the DOM: every row is several elements that the browser has to create, style, lay out and paint, and React has to reconcile all of them on every update. A filter keystroke that touches 20,000 rows means 20,000 rows of work, even though the user can see about twelve.
Render only what is visible
Virtualization, also called windowing, keeps the full list in memory and puts only the visible slice in the DOM. With fixed-height rows it is arithmetic on the scroll position:
const ROW = 36; // row height in px
const VIEW = 432; // height of the scroll area in px
const OVERSCAN = 6; // extra rows above and below, so fast scrolling shows no gaps
const first = Math.max(0, Math.floor(scrollTop / ROW) - OVERSCAN);
const last = Math.min(rows.length, Math.ceil((scrollTop + VIEW) / ROW) + OVERSCAN);
const visible = rows.slice(first, last);Then give the browser an inner element as tall as the whole list, and shift the visible slice down to where it belongs:
<div style={{ height: VIEW, overflow: 'auto' }} onScroll={(e) => setScrollTop(e.currentTarget.scrollTop)}>
{/* Full height, so the scrollbar behaves as if every row were there */}
<div style={{ height: rows.length * ROW, position: 'relative' }}>
<div style={{ transform: `translateY(${first * ROW}px)` }}>
{visible.map((row) => <Row key={row.id} row={row} />)}
</div>
</div>
</div>In the demo that turns 20,000 rows of data into roughly two dozen rows in the DOM, whatever the scroll position.
Where memoization fits
Windowing fixes how many rows exist. Memoization fixes how often the survivors re-render. Two places matter:
const Row = React.memo(function Row({ row }) {
return <div className="row">...</div>;
});
const filtered = useMemo(() => rows.filter(matches(query)), [rows, query]);- The row. Wrapped in
React.memowith a stablekey, a row that scrolls but does not change is not rendered again. - The derived list. Filtering and sorting 20,000 items on every scroll event is wasted work.
useMemorecomputes only when the inputs change.
Memoization only helps if props are stable. An inline object or arrow function passed to every row defeats it.
Keep typing responsive while the list filters
Windowing makes rendering cheap, but filtering 20,000 objects still takes time, and doing it on every keystroke makes the input lag behind the keyboard. React 18 can separate the two: the text field updates immediately and the filter runs at a lower priority.
const [query, setQuery] = useState('');
const deferredQuery = useDeferredValue(query);
// The input updates at once; the expensive filter follows when the browser has time
const filtered = useMemo(() => rows.filter(matches(deferredQuery)), [rows, deferredQuery]);If the filter is slow even then, the data set has outgrown the browser and the filtering belongs on the server.
Virtualize or paginate?
- Paginate when people look something up: they search, open one record and leave. The server filters and sorts, and each page is small.
- Virtualize when people scan and compare: transaction histories, logs, monitoring views. Scrolling is how they read, and page breaks get in the way.
- Do both when the list is too big to download at once. Fetch pages from the server as the user scrolls and virtualize whatever has arrived.
A million rows
Past a few hundred thousand rows the browser is the wrong place for the data, whatever the rendering technique. Downloading it takes longer than anyone will wait, filtering it on the main thread freezes the input, and the memory is paid by every visitor. The pattern that scales is the third option above: the server owns the data and the sort order, the client fetches pages as the user scrolls, and the virtualizer renders whatever has arrived.
const PAGE = 200;
const items = virtualizer.getVirtualItems();
const lastVisible = items[items.length - 1]?.index ?? 0;
// Within half a page of the end of what is loaded, and nothing in flight: fetch the next page
useEffect(() => {
if (hasMore && !loading && lastVisible >= rows.length - PAGE / 2) loadMore();
}, [lastVisible, rows.length, hasMore, loading]);The DOM then holds a few dozen rows whether the total is twenty thousand or twenty million. Show the server's total count in the header, so the user knows how long the list is, and reset the loaded pages when the filter or sort changes.
The same thing with react-window
In version 1 of react-window, the hand-written version above becomes one component. The style it passes to each row carries the position, so it has to be applied:
import { FixedSizeList } from 'react-window';
<FixedSizeList height={432} width="100%" itemCount={rows.length} itemSize={36} overscanCount={6}>
{({ index, style }) => (
<div style={style} className="row">{rows[index].name}</div>
)}
</FixedSizeList>The numbers are the same three as before: the height of the scroll area, the height of a row, and the overscan.
Variable row heights with TanStack Virtual
The arithmetic above assumes every row is the same height. Log lines, comments and messages are not, and guessing wrong leaves gaps or overlaps. A library that measures rows as they render solves it; TanStack Virtual does so with a resize observer, and asks only for an estimate to lay out the rows it has not seen yet:
import { useVirtualizer } from '@tanstack/react-virtual';
function Log({ entries }) {
const parentRef = useRef(null);
const virtualizer = useVirtualizer({
count: entries.length,
getScrollElement: () => parentRef.current,
estimateSize: () => 48, // a guess; rows are measured as they render
overscan: 6,
});
return (
<div ref={parentRef} style={{ height: 432, overflow: 'auto' }}>
<div style={{ height: virtualizer.getTotalSize(), position: 'relative' }}>
{virtualizer.getVirtualItems().map((row) => (
<div
key={row.key}
data-index={row.index}
ref={virtualizer.measureElement}
style={{
position: 'absolute',
top: 0,
width: '100%',
transform: `translateY(${row.start}px)`,
}}
>
{entries[row.index].message}
</div>
))}
</div>
</div>
);
}Three details carry the weight. estimateSize should be close to the largest common height, so positions start near their final values. measureElement on the row's ref, together with data-index, is what reports the real height back. And getTotalSize() grows and shrinks as measurements arrive, so the scrollbar stays honest. The same hook handles fixed heights, columns and grids, so it is a reasonable default for new work.
Headers and wide tables
Keep the header row outside the scrolling element, or make it position: sticky, so it does not scroll away with the rows. Column widths must then be fixed or shared between header and body, because the rows no longer sit in one table layout that sizes them together. If the table is wide as well as long, the same arithmetic works sideways: render only the columns in view.
What the timer actually measures
The demo starts its clock inside the input handler, changes state, then reads the clock in the second animation-frame callback. Each interaction captures its own start time. This is an update-delay estimate, not a paint timestamp:
const started = performance.now();
setQuery(next);
requestAnimationFrame(() =>
requestAnimationFrame(() => console.log(Math.round(performance.now() - started), 'ms update delay estimate')),
);Animation-frame callbacks run before repaint, depend on the display refresh rate and may pause in background tabs. Two callbacks do not guarantee that a particular React update was painted. Fast results can mostly reflect frame scheduling, and slow results can include unrelated main-thread work. For React render duration use React's Profiler in a profiling-enabled build, separately from this normal production-build comparison.
What to watch for
- Variable row heights. The arithmetic above needs a fixed height. For rows that grow, use a library that measures them, as in the TanStack Virtual example.
- Find in page. The browser's search cannot see rows that are not in the DOM. Provide your own filter, as the demo does.
- Accessibility. Tell assistive technology the real size with
aria-rowcountandaria-rowindex, and make the scroll area focusable so it can be scrolled from the keyboard. - Production use. For real products use a maintained library such as react-window. It handles the edge cases; the principle is exactly the one above.
- 20,000
- rows in the data
- 18
- rows in the DOM
- –
- update delay estimate
Synthetic data. Timing runs from the update handler to the second animation-frame callback, rounded to milliseconds. It includes frame scheduling and is not a paint timestamp. Compare the same filter action in each mode.
Quick answers
The short version
What is virtualization in React?
Rendering only the rows that are visible in the scroll area, plus a few either side, while the full list stays in memory. It is also called windowing.
How many rows can a React table handle?
It depends on row complexity, device and interaction. This synthetic example keeps 20,000 rows in memory but mounts 18 at scroll position zero. The article reports repeatable filter measurements, not a universal row limit.
Should I use virtualization or pagination?
Paginate when users look things up and the server can filter and sort. Virtualize when users scan or compare a long list and scrolling is the natural way to read it.
How do I virtualize rows with different heights?
Use a library that measures rows as they render. With TanStack Virtual, give it an estimateSize and attach measureElement to each row; positions are corrected as the real heights arrive.
Can a React table show a million rows?
Not by loading them all. Keep the data on the server, fetch it in pages as the user scrolls, and virtualize whatever has arrived. The DOM then holds a few dozen rows whatever the total.
Is react-window better than writing it by hand?
For production, yes. It is maintained and handles the edge cases. Writing the fixed-height version once by hand is still the quickest way to understand what the library does.
Keep reading
Related articles
- Passing Core Web Vitals in a React app: what moves LCPHow to find the element that sets your LCP, ship less before the first paint with code splitting, preload only what matters, and measure the change properly.
- A real-time React dashboard that keeps up with WebSocketsWhy a live dashboard slows down over time, and the fixes: render once per frame, cap the list, aggregate as events arrive, and plan for reconnects.
- A React custom hooks library a team will actually useWhich hooks belong in a shared React library, useSyncExternalStore for browser state, useEffectEvent for stale closures, and testing hooks with renderHook.
The project behind this
Read the case study
What I built, where, and the numbers that came out of it.
Related experience: Frontend developer.