A tiny, dynamic list virtualization library for React
npm install mini-virtual-listnpm i mini-virtual-list
A tiny, speedy list virtualization library for React
- [x] Easy to use This component comes with the important batteries included and an easy to understand API.
- [x] Versatile Supports list items with both variable and fixed heights.
- Variable size example on CodeSandbox
- Fixed size example on CodeSandbox
- [x] Blazing™ fast The fixed-size hooks and components have O(1) search performance, while the dynamic-size hooks and
components use binary search and have O(log(n)) worst case performance.
- [x] TypeScript Woohoo! Superior autocomplete and _strict types_ mean fewer bugs in your implementation.
``jsx harmony
import React, { useState, useLayoutEffect, useRef } from "react";
import randInt from "random-int";
import { List, useScroller, useSize } from "mini-virtual-list";
let items = [];
for (let i = 10000 cur; i < cur 10000 + 10000; i++)
items.push({ id: i, initialHeight: randInt(40, 140) });
const ListComponent = () => {
const ref = useRef(null);
const scroll = useScroller(ref);
const size = useSize(ref);
return (
API
$3
| Component | Description |
| ------------------------------- | ------------------------------------------------- |
|
| A tiny, fast fixed-size virtual list component. |
| | A tiny, fast dynamic-size virtual list component. |$3
| Hook | Description |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
useList() | A fixed-size virtual list hook |
| useDynamicList() | A dynamic-size virtual list hook |
| usePositioner() | A list item positioner for useDynamicList()](#usedynamiclist) |
| useSize() | A convenient hook for providing the container size to the component |
| useScroller()` | A hook used for tracking a container node's scroll position. These values are used when calculating the number of rows to render and determining when we should disable pointer events on the masonry container to maximize scroll performance. |---
#### Props
| Prop | Type | Default | Required? | Description |
| ---- | ---- | ------- | --------- | ----------- |
| | | | | |
---
#### Props
| Prop | Type | Default | Required? | Description |
| ---- | ---- | ------- | --------- | ----------- |
| | | | | |
---
#### Arguments
| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
| | | | | |
---
#### Arguments
| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
| | | | | |
---
#### Arguments
| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
| | | | | |
---
#### Arguments
| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
| | | | | |
#### Returns
---
#### Arguments
| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
| | | | | |
#### Returns
MIT