rc-virtual-list is a React component designed for efficiently rendering large lists by only rendering items visible within the viewport, significantly improving performance and memory usage compared to rendering all items simultaneously. It supports animations and is compatible with older browsers like IE11+. The package, currently at stable version `3.19.2`, receives regular patch updates, indicating an active maintenance schedule. It is part of the `react-component` ecosystem, known for providing foundational UI components often utilized within Ant Design. Its key differentiators include built-in animation support, broad browser compatibility, and a focus on core virtualization logic without opinionated styling, making it highly adaptable to various design systems. It enables smooth scrolling and interaction even with thousands of data entries by precisely managing what's rendered to the DOM.
npm install rc-virtual-listVerified import paths — ran on the pinned version, not inferred.
This quickstart renders a virtualized list with 1000 items, demonstrating basic setup and usage of `rc-virtual-list`.
Monitor the official `rc-virtual-list` GitHub repository for announcements regarding transitions or consolidations. For existing projects, continue using `rc-virtual-list` `3.x.x` unless a migration path is clearly documented. For new projects, evaluate whether to start with `@rc-component/virtual-list` if it appears to be the future stable branch.
Ensure `itemKey` is set to a stable, unique identifier for each item in your `data` array (e.g., `item.id`). If items do not have a natural unique ID, consider generating one, or use a combination of properties that guarantees uniqueness across renders.
For lists with dynamically sized items, ensure `itemHeight` is either an accurate average or estimated height. If heights vary significantly, consider implementing mechanisms to dynamically measure item heights or use a virtualized list solution specifically designed for variable height items if `rc-virtual-list`'s API doesn't fully support it (e.g., providing a `measure` prop if available).
This is an internal change; most users are unaffected. If encountering unexpected DOM-related issues after upgrading, re-evaluate any code that directly or indirectly interacts with the component's underlying DOM structure, and prefer using React refs for direct DOM access instead of relying on `findDOMNode`.
Set the `itemKey` prop to a stable, unique identifier for each item in your `data`. For example, `<List data={items} itemKey="id">`.Ensure you are using `React.useRef` (or `createRef` for class components) and accessing the method only after the component has rendered and the ref's `current` property is not null. Example: `listRef.current?.scrollTo(offset);`
Verify `itemKey` is unique and stable. If item heights vary, ensure `itemHeight` is an accurate average or estimated height for proper scroll calculations. Check if the `data` prop is changing as expected and not being incorrectly memoized, preventing the list from updating.