npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mini-virtual-list

v0.3.2

Published

A tiny, dynamic list virtualization library for React

Downloads

8,334

Readme

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

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