
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
kd-react-virtual-list
Advanced tools
Super simple virtualized list higher-order component for React version ^15.0.0 || ^16.0.0.
react-virtual-list allows you to display a large list of fixed-height items, while only rendering the items visible on the screen. This allows a large list to be rendered with much fewer DOM elements.
prop-types)If you're looking for documentation on version 1, supporting React ~0.13.x, it's here.
You can use npm to install react-virtual-list.
> npm install react-virtual-list --save
The ./lib/VirtualList.js module exports a single, ES5-compatible, CommonJS-accessible, component factory.
import VirtualList from 'react-virtual-list';
Your inner list component uses the virtual property to render the visible items, and set a style to set the overall list height and padding.
const MyList = ({
virtual,
itemHeight,
}) => (
<ul style={virtual.style}>
{virtual.items.map(item => (
<li key={`item_${item.id}`} style={{height: itemHeight}}>
Lorem ipsum dolor sit amet
</li>
))}
</ul>
);
Note: You should set keys on your list items.
Create the virtualized component.
const MyVirtualList = VirtualList()(MyList);
Write the JSX for the virtualized component with the necessary properties.
<MyVirtualList
items={myBigListOfItems}
itemHeight={100}
/>
Options are used before the virtualized component can be created. This means that if you need to change an option after the initial render, you will need to recreate the virtualized component.
const options = {
container: this.refs.container, // use this scrollable element as a container
initialState: {
firstItemIndex: 0, // show first ten items
lastItemIndex: 9, // during initial render
},
};
const MyVirtualList = VirtualList(options)(MyList);
| Name | Type | Default | Description |
|---|---|---|---|
container | DOM Element | window | Scrollable element that contains the list. Use this if you have a list inside an element with overflow: scroll. |
initialState | object | - | An object with firstItemIndex and lastItemIndex properties, which represent array indexes of items (see below). These are used to calculate the visible items before the component is mounted. Useful for server-side rendering. |
These properties and any others set on your virtual component, such as className, will be passed down to the inner component.
| Name | Type | Default | Description |
|---|---|---|---|
items | Array | - | Full array of list items. Only the visible subset of these will be rendered. |
itemHeight | Number | - | Height in pixels of a single item. You must have a CSS rule that sets the height of each list item to this value. |
itemBuffer | Number | 0 | Number of items that should be rendered before and after the visible viewport. Try using this if you have a complex list that suffers from a bit of lag when scrolling. |
VirtualList allows a second, optional, parameter, named mapVirtualToProps, which functions similarly to Redux's mapStateToProps. This function can be provided to change the properties passed to MyList. Its arguments are:
| Name | Description |
|---|---|
props | Includes all properties passed to MyVirtualList |
state | Includes firstItemIndex and lastItemIndex; array indexes of the visible bounds of items |
The default mapVirtualToProps can be found here.
Check out demo/src/app.js and demo/src/ConfigurableExample.js for the example used in the demo.
Use npm test to run the tests using Jest. Not everything is currently tested yet!
FAQs
Super simple virtualized list React higher-order component
We found that kd-react-virtual-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.