Détail du package

mini-virtual-list

jaredLunde12.6kMIT0.3.2

A tiny, dynamic list virtualization library for React

react, react component, mini virtual list, mini virtualized list

readme


mini-virtual-list

Bundlephobia Types Code coverage Build status NPM Version MIT License

npm i mini-virtual-list


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.
  • [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 (

<List items={items} itemHeight={36} {...size} {...scroll} render={FakeCard} />
); }; ```

API

Components

Component Description
<List> A tiny, fast fixed-size virtual list component.
<DynamicList> A tiny, fast dynamic-size virtual list component.

Hooks

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 <List> 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.

<List>

Props

Prop Type Default Required? Description

<DynamicList>

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

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.3.2 (2021-12-12)

Bug Fixes

  • fix window not being defined in ssr (3db767f)

0.3.1 (2020-08-20)

Bug Fixes

  • types: make innerRef optional (255081b)

0.3.0 (2020-08-20)

⚠ BREAKING CHANGES

  • dynamic: Renames useDynamicListElements() to useDynamicListItems()
  • Adding generic types forced me to replace ref forwarding with an innerRef prop.

Features

  • dynamic: rename useDynamicListItems to useDynamicListElements (057ccf9)
  • use-scroller: allow any scrollable element as a reference (e2eb3b6)
  • add generic types (855ac19)

Bug Fixes

  • use-size: fix generic type (fff385d)

0.2.0 (2020-07-03)