These libraries solve the problem of displaying large lists in React applications without crashing the browser. react-window and react-virtualized use virtualization to render only the visible items, recycling DOM nodes to keep memory usage low. react-infinite-scroll-component appends items to the DOM as the user scrolls, which is simpler but can cause performance issues with very large data sets. react-tiny-virtual-list offers a lightweight virtualization approach with a simpler API than the larger frameworks. Choosing the right tool depends on whether you need true virtualization for performance or a simple append-on-scroll behavior for easier implementation.
When building React applications, rendering long lists can slow down your app or crash the browser. The packages react-window, react-virtualized, react-tiny-virtual-list, and react-infinite-scroll-component solve this problem in different ways. The key difference lies in how they handle DOM nodes: virtualization recycles nodes, while infinite scroll keeps appending them. Let's compare how they work in real engineering scenarios.
react-window renders only the items visible in the viewport. It creates a fixed container and moves items within it as you scroll.
import { FixedSizeList } from 'react-window';
const List = ({ items }) => (
<FixedSizeList height={500} itemCount={items.length} itemSize={35} width={300}>
{({ index, style }) => (
<div style={style}>
{items[index]}
</div>
)}
</FixedSizeList>
);
react-virtualized works similarly but uses a slightly older API structure with explicit row renderers.
import { List } from 'react-virtualized';
const List = ({ items }) => (
<List
height={500}
rowCount={items.length}
rowHeight={35}
width={300}
rowRenderer={({ index, key, style }) => (
<div key={key} style={style}>
{items[index]}
</div>
)}
/>
);
react-tiny-virtual-list provides a similar virtualization experience with a simpler prop structure focused on rendering items.
import VirtualList from 'react-tiny-virtual-list';
const List = ({ items }) => (
<VirtualList
width={300}
height={500}
itemCount={items.length}
itemSize={35}
renderItem={({ index }) => (
<div key={index}>
{items[index]}
</div>
)}
/>
);
react-infinite-scroll-component does not virtualize. It renders all children and appends more as you reach the bottom. This means DOM nodes accumulate over time.
import InfiniteScroll from 'react-infinite-scroll-component';
const List = ({ items, fetchMore }) => (
<InfiniteScroll
dataLength={items.length}
next={fetchMore}
hasMore={true}
loader={<h4>Loading...</h4>}
height={500}
>
{items.map((item, index) => (
<div key={index}>{item}</div>
))}
</InfiniteScroll>
);
Managing the width and height of the list container is critical for virtualization to calculate visible items correctly.
react-window includes a separate AutoSizer component to fill the parent container automatically.
import { FixedSizeList } from 'react-window';
import AutoSizer from 'react-virtualized-auto-sizer';
const List = ({ items }) => (
<AutoSizer>
{({ height, width }) => (
<FixedSizeList height={height} width={width} itemCount={items.length} itemSize={35}>
{({ index, style }) => <div style={style}>{items[index]}</div>}
</FixedSizeList>
)}
</AutoSizer>
);
react-virtualized also uses AutoSizer but integrates it tightly within its own ecosystem.
import { List, AutoSizer } from 'react-virtualized';
const List = ({ items }) => (
<AutoSizer>
{({ height, width }) => (
<List
height={height}
width={width}
rowCount={items.length}
rowHeight={35}
rowRenderer={({ index, key, style }) => <div key={key} style={style}>{items[index]}</div>}
/>
)}
</AutoSizer>
);
react-tiny-virtual-list typically requires manual width and height props or CSS styling on the wrapper element.
import VirtualList from 'react-tiny-virtual-list';
const List = ({ items }) => (
<div style={{ width: '100%', height: '500px' }}>
<VirtualList
width={300}
height={500}
itemCount={items.length}
itemSize={35}
renderItem={({ index }) => <div key={index}>{items[index]}</div>}
/>
</div>
);
react-infinite-scroll-component relies on CSS or explicit height props to define the scrollable area.
import InfiniteScroll from 'react-infinite-scroll-component';
const List = ({ items, fetchMore }) => (
<div style={{ height: '500px', overflow: 'auto' }}>
<InfiniteScroll
dataLength={items.length}
next={fetchMore}
hasMore={true}
loader={<h4>Loading...</h4>}
height={500}
>
{items.map((item, index) => <div key={index}>{item}</div>)}
</InfiniteScroll>
</div>
);
Fetching additional data as the user scrolls is a common requirement. The implementation differs between virtualizers and infinite scroll wrappers.
react-window does not handle data fetching internally. You must track the scroll index and trigger fetches manually.
import { FixedSizeList } from 'react-window';
const List = ({ items, fetchMore }) => {
const onItemsRendered = ({ visibleStopIndex }) => {
if (visibleStopIndex >= items.length - 5) fetchMore();
};
return (
<FixedSizeList height={500} itemCount={items.length} itemSize={35} width={300} onItemsRendered={onItemsRendered}>
{({ index, style }) => <div style={style}>{items[index]}</div>}
</FixedSizeList>
);
};
react-virtualized uses a similar manual approach with the onRowsRendered callback.
import { List } from 'react-virtualized';
const List = ({ items, fetchMore }) => (
<List
height={500}
rowCount={items.length}
rowHeight={35}
width={300}
onRowsRendered={({ stopIndex }) => {
if (stopIndex >= items.length - 5) fetchMore();
}}
rowRenderer={({ index, key, style }) => <div key={key} style={style}>{items[index]}</div>}
/>
);
react-tiny-virtual-list requires you to implement logic outside the component to check scroll position or rendered indices.
import VirtualList from 'react-tiny-virtual-list';
const List = ({ items, fetchMore }) => (
<VirtualList
width={300}
height={500}
itemCount={items.length}
itemSize={35}
renderItem={({ index }) => <div key={index}>{items[index]}</div>}
// You must wrap this or use refs to track scroll for fetchMore
/>
);
react-infinite-scroll-component has data loading built-in via the next prop, making it the easiest to set up for simple feeds.
import InfiniteScroll from 'react-infinite-scroll-component';
const List = ({ items, fetchMore }) => (
<InfiniteScroll
dataLength={items.length}
next={fetchMore}
hasMore={true}
loader={<h4>Loading...</h4>}
height={500}
>
{items.map((item, index) => <div key={index}>{item}</div>)}
</InfiniteScroll>
);
Choosing a library involves considering its future support. Some packages are no longer actively developed.
react-window is actively maintained by Brian Vaughn at Vercel. It is the recommended path for virtualization in the React ecosystem.
// react-window is the current standard
import { FixedSizeList } from 'react-window';
react-virtualized is in maintenance mode. The author recommends migrating to react-window. Do not use it for new projects.
// react-virtualized is legacy
// Only use for existing projects
import { List } from 'react-virtualized';
react-tiny-virtual-list has less frequent updates but remains functional for simple use cases. Check the repository for recent activity before committing.
// react-tiny-virtual-list is stable but less active
import VirtualList from 'react-tiny-virtual-list';
react-infinite-scroll-component is widely used and maintained. It solves a different problem (appending vs virtualizing), so it remains relevant for specific UI patterns.
// react-infinite-scroll-component is active
import InfiniteScroll from 'react-infinite-scroll-component';
| Feature | react-window | react-virtualized | react-tiny-virtual-list | react-infinite-scroll-component |
|---|---|---|---|---|
| Strategy | Virtualization | Virtualization | Virtualization | DOM Appending |
| Maintenance | ā Active | ā ļø Legacy | ā ļø Stable | ā Active |
| API Complexity | Medium | High | Low | Low |
| AutoSizer | ā External Component | ā Built-in | ā Manual | ā Manual |
| Data Loading | ā Manual | ā Manual | ā Manual | ā Built-in |
| Performance | š High | š High | š High | ā ļø Degrades with size |
react-window is the best choice for most modern applications requiring virtualization. It balances performance with a maintainable codebase and active support.
react-infinite-scroll-component is perfect for social feeds or comment sections where simplicity matters more than handling tens of thousands of items.
react-virtualized should be avoided in new work. If you inherit a project using it, plan to migrate to react-window when possible.
react-tiny-virtual-list is a viable alternative if you need virtualization but find react-window too heavy or complex for your specific needs.
Avoid react-virtualized for new projects as it is in maintenance mode and no longer receives feature updates. Only choose this if you are maintaining a legacy codebase that already depends on it, or if you need a specific feature not present in react-window like complex table headers with heavy customization.
Choose react-infinite-scroll-component when you need a simple infinite scroll effect and the total list size will remain manageable (e.g., under 1,000 items). It is best for social media feeds or comment sections where DOM node recycling is less critical than implementation speed.
Choose react-tiny-virtual-list if you need virtualization but want a simpler API with fewer dependencies than react-window. It works well for standard lists with fixed item heights where you do not need the advanced grid or table features of the larger libraries.
Choose react-window for new projects requiring high-performance virtualization. It is the modern successor to react-virtualized, maintained by the same author, and offers a smaller bundle size with a focused API. It is ideal for dashboards, data grids, and any list with thousands of rows where scrolling smoothness is critical.
React components for efficiently rendering large lists and tabular data. Check out the demo for some examples.
The following wonderful companies have sponsored react-virtualized:
Learn more about becoming a sponsor!
react-windowIf you're considering adding react-virtualized to a project, take a look at react-window as a possible lighter-weight alternative. Learn more about how the two libraries compare here.
Install react-virtualized using npm.
npm install react-virtualized --save
ES6, CommonJS, and UMD builds are available with each distribution. For example:
// Most of react-virtualized's styles are functional (eg position, size).
// Functional styles are applied directly to DOM elements.
// The Table component ships with a few presentational styles as well.
// They are optional, but if you want them you will need to also import the CSS file.
// This only needs to be done once; probably during your application's bootstrapping process.
import 'react-virtualized/styles.css';
// You can import any component you want as a named export from 'react-virtualized', eg
import {Column, Table} from 'react-virtualized';
// But if you only use a few react-virtualized components,
// And you're concerned about increasing your application's bundle size,
// You can directly import only the components you need, like so:
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
import List from 'react-virtualized/dist/commonjs/List';
Note webpack 4 makes this optimization itself, see the documentation.
If the above syntax looks too cumbersome, or you import react-virtualized components from a lot of places, you can also configure a Webpack alias. For example:
// Partial webpack.config.js
{
alias: {
'react-virtualized/List': 'react-virtualized/dist/es/List',
},
...rest
}
Then you can just import like so:
import List from 'react-virtualized/List';
// Now you can use <List {...props} />
You can also use a global-friendly UMD build:
<link rel="stylesheet" href="path-to-react-virtualized/styles.css" />
<script src="path-to-react-virtualized/dist/umd/react-virtualized.js"></script>
Now you're ready to start using the components. You can learn more about which components react-virtualized has to offer below.
React Virtualized has very few dependencies and most are managed by NPM automatically.
However the following peer dependencies must be specified by your project in order to avoid version conflicts:
react,
react-dom.
NPM will not automatically install these for you but it will show you a warning message with instructions on how to install them.
By default all react-virtualized components use shallowCompare to avoid re-rendering unless props or state has changed.
This occasionally confuses users when a collection's data changes (eg ['a','b','c'] => ['d','e','f']) but props do not (eg array.length).
The solution to this is to let react-virtualized know that something external has changed. This can be done a couple of different ways.
The shallowCompare method will detect changes to any props, even if they aren't declared as propTypes.
This means you can also pass through additional properties that affect cell rendering to ensure changes are detected.
For example, if you're using List to render a list of items that may be re-sorted after initial render- react-virtualized would not normally detect the sort operation because none of the properties it deals with change.
However you can pass through the additional sort property to trigger a re-render.
For example:
<List {...listProps} sortBy={sortBy} />
Grid and Collection components can be forcefully re-rendered using forceUpdate.
For Table and List, you'll need to call forceUpdateGrid to ensure that the inner Grid is also updated. For MultiGrid, you'll need to call forceUpdateGrids to ensure that the inner Grids are updated.
API documentation available here.
There are also a couple of how-to guides:
Examples for each component can be seen in the documentation.
Here are some online demos of each component:
And here are some "recipe" type demos:
react-virtualized aims to support all evergreen browsers and recent mobile browsers for iOS and Android. IE 9+ is also supported (although IE 9 will require some user-defined, custom CSS since flexbox layout is not supported).
If you find a browser-specific problem, please report it along with a repro case. The easiest way to do this is probably by forking this Plunker.
Here are some great components built on top of react-virtualized:
Use GitHub issues for requests.
I actively welcome pull requests; learn how to contribute.
Changes are tracked in the changelog.
react-virtualized is available under the MIT License.