Hint
Render only visible items in a long list — react-window / react-virtual renders a DOM window into a large dataset
Virtualization renders only the items visible in the viewport instead of the entire list. For 10,000 items, you might only render 20 DOM nodes at a time.
import { FixedSizeList } from 'react-window';
// ❌ Renders all 10,000 DOM nodes immediately
function NaiveList({ items }) {
return items.map(item =>
);
}
// ✅ Renders ~20 DOM nodes, recycles them as you scroll
function VirtualList({ items }) {
const Row = ({ index, style }) => (
{/* style positions the row */}
{items[index].name}
);
return (
{Row}
);
}
When to virtualize:
Libraries: react-window (smaller), react-virtual (TanStack, headless), react-virtuoso (variable heights)