Virtualizing long lists in React: when react-window isn't enough and you need server-side pagination
A React list that renders thousands of rows almost always hits the same wall: scrolling gets heavy, the initial render takes too long, and someone on the team suggests react-window. Most of the time that's the right call, and it works well. But we keep seeing the same mistake: treating client-side virtualization as a fix for any long-list problem, when it actually solves one very specific problem — and there's a different one that only gets fixed by changing where pagination lives.
What virtualization fixes, and what it doesn't
Rendering a list of several thousand items without virtualization means creating several thousand DOM nodes at once. The browser has to compute layout for all of them, even though the user only sees twenty at a time inside the visible viewport. That's exactly what react-window removes: instead of mounting one node per item, it keeps only the nodes that fall inside the viewport plus an overscan margin, and recycles those nodes as the user scrolls.
What react-window never touches is how those items got to the client in the first place. If the full array is already sitting in memory because the backend sent it whole in a single response, virtualization does its job perfectly from that point on. But if the actual problem is that shipping the entire array is already expensive — because of payload size, server-side serialization time, or the memory a browser tab has to hold before React paints a single row — no amount of tuning itemSize or overscanCount fixes it, because the bottleneck sits upstream of where virtualization even starts to help.
The symptom that blurs the two causes
The signal we use to tell the two problems apart is where the slowness shows up, not how much slowness there is. If the user waits several seconds before the first row appears, and that wait lines up with a request still "pending" in the Network tab, it's a data problem: the client is fetching more than it needs to paint the first screen. If the first screen appears quickly but scrolling stutters or drops frames as the user moves through the list, it's a render problem, and that's where virtualization is the right tool.
The two are easy to confuse because from the user's side both look the same: "the list is slow." That's why, before touching any code, the first step is opening the Network profiler and the Performance profiler separately and looking at each before deciding what to change.
Pure virtualization: when the whole dataset fits in memory
There's a case where react-window alone, without touching backend pagination, is the right answer: when the dataset has a bounded size by design, not by coincidence. A small business's product catalog, a list of configuration entries, an employee directory — these grow with the business, but within an order of magnitude that's still reasonable to ship to the client in full.
import { FixedSizeList as List } from 'react-window';
function ClientTable({ clients }) {
const Row = ({ index, style }) => {
const client = clients[index];
return (
<div style={style} className="client-row">
{client.name} — {client.email}
</div>
);
};
return (
<List height={600} itemCount={clients.length} itemSize={48} width="100%">
{Row}
</List>
);
}
This component receives the full array already resolved — for example, from a single API call that returns every client on an account — and leaves it to react-window to decide which rows to mount based on scroll position. There's no pagination of any kind, client or server side, because none is needed: the whole dataset is manageable as is.
When the dataset stops being bounded
The problem shows up when that same table, over time, starts representing something with no natural ceiling: an audit log, a transaction history, an events table. At that point the array no longer has a reasonable cap, and asking the backend to return "everything" stops being an option, no matter how efficient the render-side virtualization is. The JSON payload grows, server-side serialization time grows, and the browser holds an array in memory that's no longer trivial — all of that before react-window ever gets a chance to help.
At that point the fix isn't tuning virtualization further. It's moving the boundary of "how many items exist on the client at any given moment" from the size of the whole dataset down to the size of one page.
Server-side pagination combined with virtualization
The pattern we use for unbounded lists is infinite scroll with cursor-based pagination on the backend, with virtualization applied only to what's already been loaded. The core idea is that the client never knows, and never needs to know, how many items exist in total: it requests a page, appends it to what it already has, and when the user gets close to the end of what's loaded, it requests the next one.
import { FixedSizeList as List } from 'react-window';
import InfiniteLoader from 'react-window-infinite-loader';
function EventsTable({ events, hasMoreToLoad, loadNextPage }) {
const itemCount = hasMoreToLoad ? events.length + 1 : events.length;
const isItemLoaded = (index) => !hasMoreToLoad || index < events.length;
const Row = ({ index, style }) => {
if (!isItemLoaded(index)) {
return <div style={style}>Loading…</div>;
}
const event = events[index];
return (
<div style={style} className="event-row">
{event.timestamp} — {event.description}
</div>
);
};
return (
<InfiniteLoader
isItemLoaded={isItemLoaded}
itemCount={itemCount}
loadMoreItems={loadNextPage}
>
{({ onItemsRendered, ref }) => (
<List
height={600}
itemCount={itemCount}
itemSize={44}
width="100%"
onItemsRendered={onItemsRendered}
ref={ref}
>
{Row}
</List>
)}
</InfiniteLoader>
);
}
loadNextPage calls the backend with a cursor — the id or timestamp of the last item received, not a page number — because a numeric offset becomes inconsistent if rows get inserted or deleted while the user keeps scrolling. The backend keeps returning bounded batches of roughly the same size, so neither the network payload nor the client's in-memory array grows out of control, no matter how large the underlying table actually gets.
The criterion for choosing between the two
The criterion we use isn't "how many rows does the list have today," it's whether that number has a natural ceiling or not. A dataset that grows with a business's catalog but settles at a known order of magnitude — hundreds or a few thousand — is a good candidate for pure virtualization, because the cost of fetching it whole, once, is low and roughly constant. A dataset that grows with system usage — events, transactions, messages, logs — has no such ceiling, and there server-side pagination isn't an optional optimization, it's the only way to keep the list's size from depending on how long the product has been in use.
What didn't work on the first try
On an events dashboard for a client, the initial symptom was a long load time, and the first fix we tried was tuning react-window's parameters: raising overscanCount on the assumption that scrolling needed a bigger pre-render margin, and lowering the estimated itemSize for a more accurate height calculation. Nothing changed, because the wait wasn't happening during scroll — it was happening before, while the browser waited for a single request to come back with the entire event history as one JSON payload. The Performance profiler didn't even register render activity during that stretch, because React had no data yet to paint anything with.
The second attempt got closer but was still incomplete: we moved to pagination with batches of several thousand items per page, without virtualization, assuming that fixing the network side made virtualization unnecessary. That just moved the problem from the network to the render: each "page" was still too large to mount in one go without stalling the UI. What actually worked was shrinking each page to a batch size the backend resolves quickly and that fits comfortably in a single fetch, combined with virtualization over the full accumulated set of pages already loaded, not over one page at a time.
What we check before calling a long list done
Before closing out this kind of work, we separate the Network profile from the Performance profile and confirm which one actually shows the slowdown, instead of assuming it from the reported symptom. We check whether the underlying dataset has a known growth ceiling or grows with product usage, because that answer decides whether pure virtualization is enough or pagination needs to move to the server. And whenever there's server-side pagination, we confirm the cursor used to request the next page doesn't depend on a numeric offset that breaks if the underlying table changes while the user is still scrolling.