# mini-virtual-list

> A tiny, dynamic list virtualization library for React

Latest version **0.3.2** (published 2021-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install mini-virtual-list
pnpm add mini-virtual-list
yarn add mini-virtual-list
bun add mini-virtual-list
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2021-12-12 |
| First published | 2020-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 270.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Maintainers | jaredlunde |
| Keywords | react, react component, mini virtual list, mini virtualized list, virtualized list, virtual list, virtual list component, virtualized list component, react virtual list, react virtualized list, react virtual list component, react virtualized list component |

## Links

- npm: https://www.npmjs.com/package/mini-virtual-list
- Repository: https://github.com/jaredLunde/mini-virtual-list
- Homepage: https://github.com/jaredLunde/mini-virtual-list#readme
- Issues: https://github.com/jaredLunde/mini-virtual-list/issues
- npm.io page: https://npm.io/package/mini-virtual-list

## Dependencies (5)

- [@react-hook/event](https://npm.io/package/@react-hook/event.md) ^1.2.6
- [@react-hook/throttle](https://npm.io/package/@react-hook/throttle.md) ^2.2.0
- [@essentials/memoize-one](https://npm.io/package/@essentials/memoize-one.md) ^1.1.0
- [@essentials/request-timeout](https://npm.io/package/@essentials/request-timeout.md) ^1.3.0
- [@react-hook/passive-layout-effect](https://npm.io/package/@react-hook/passive-layout-effect.md) ^1.2.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2021-12-12
- 0.3.1 — 2020-08-20
- 0.3.0 — 2020-08-20
- 0.2.0 — 2020-06-05
- 0.1.14 — 2020-05-03
- 0.1.13 — 2020-05-02
- 0.1.12 — 2020-05-01
- 0.1.11 — 2020-05-01
- 0.1.10 — 2020-05-01
- 0.1.9 — 2020-04-30
- 0.1.8 — 2020-04-30
- 0.1.7 — 2020-04-30
- 0.1.6 — 2020-04-30
- 0.1.5 — 2020-04-30
- 0.1.4 — 2020-04-30
- … 13 more at https://npm.io/package/mini-virtual-list/versions

## README

<hr>
<div align="center">
  <h1 align="center">
    mini-virtual-list
  </h1>
</div>

<p align="center">
  <a href="https://bundlephobia.com/result?p=mini-virtual-list">
    <img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/mini-virtual-list?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="Types" href="https://www.npmjs.com/package/mini-virtual-list">
    <img alt="Types" src="https://img.shields.io/npm/types/mini-virtual-list?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="Code coverage report" href="https://codecov.io/gh/jaredLunde/mini-virtual-list">
    <img alt="Code coverage" src="https://img.shields.io/codecov/c/gh/jaredLunde/mini-virtual-list?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="Build status" href="https://travis-ci.com/jaredLunde/mini-virtual-list">
    <img alt="Build status" src="https://img.shields.io/travis/com/jaredLunde/mini-virtual-list?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="NPM version" href="https://www.npmjs.com/package/mini-virtual-list">
    <img alt="NPM Version" src="https://img.shields.io/npm/v/mini-virtual-list?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="License" href="https://jaredlunde.mit-license.org/">
    <img alt="MIT License" src="https://img.shields.io/npm/l/mini-virtual-list?style=for-the-badge&labelColor=24292e">
  </a>
</p>

<pre align="center">npm i mini-virtual-list</pre>
<hr>

A tiny, speedy list virtualization library for React

## Features

- [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**](https://codesandbox.io/s/mini-virtual-list-example-r7fxt?file=/src/App.js)
  - [Fixed size example on **CodeSandbox**](https://codesandbox.io/s/mini-virtual-list-fixed-example-q96ty?file=/src/App.js)
- [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.

## Quick Start

```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 (
    <div
      style={{
        height: 540,
        width: 320,
        overflow: "auto",
      }}
      ref={ref}
    >
      <List
        items={items}
        itemHeight={36}
        {...size}
        {...scroll}
        render={FakeCard}
      />
    </div>
  );
};
```

## API

### Components

| Component                       | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<List>`](#list)               | A tiny, fast fixed-size virtual list component.   |
| [`<DynamicList>`](#dynamiclist) | A tiny, fast dynamic-size virtual list component. |

### Hooks

| Hook                                  | Description                                                                                                                                                                                                                                     |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`useList()`](#uselist)               | A fixed-size virtual list hook                                                                                                                                                                                                                  |
| [`useDynamicList()`](#usedynamiclist) | A dynamic-size virtual list hook                                                                                                                                                                                                                |
| [`usePositioner()`](#usepositioner)   | A list item positioner for `useDynamicList()`](#usedynamiclist)                                                                                                                                                                                 |
| [`useSize()`](#usesize)               | A convenient hook for providing the container size to the `<List>` component                                                                                                                                                                    |
| [`useScroller()`](#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. |

---

### &lt;List&gt;

#### Props

| Prop | Type | Default | Required? | Description |
| ---- | ---- | ------- | --------- | ----------- |
|      |      |         |           |             |

---

### &lt;DynamicList&gt;

#### Props

| Prop | Type | Default | Required? | Description |
| ---- | ---- | ------- | --------- | ----------- |
|      |      |         |           |             |

---

### useList()

#### Arguments

| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
|          |      |         |           |             |

---

### useDynamicList()

#### Arguments

| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
|          |      |         |           |             |

---

### usePositioner()

#### Arguments

| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
|          |      |         |           |             |

---

### useSize()

#### Arguments

| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
|          |      |         |           |             |

#### Returns

---

### useScroller()

#### Arguments

| Argument | Type | Default | Required? | Description |
| -------- | ---- | ------- | --------- | ----------- |
|          |      |         |           |             |

#### Returns

## LICENSE

MIT

---
_Source: https://npm.io/package/mini-virtual-list · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
