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

@dwqs/react-virtual-list

v1.0.0

Published

A tiny virtualization list component, supports variable height

Downloads

26

Readme

npm-version license js-standard-style travis-ci

README 中文

react-virtual-list

A tiny virtualization list component, supports dynamic height.

Attention: On iOS UIWebViews, scroll events are not fired while scrolling is taking place; they are only fired after the scrolling has completed. See more

Install

Using npm or yarn:

// npm
npm install @dwqs/react-virtual-list --save

// yarn
yarn add @dwqs/react-virtual-list

Basic usage

import React, { Component } from 'react'
import VirtualizedList from '@dwqs/react-virtual-list'

export default class Hello extends Component {
  constructor (props) {
    super(props)
    this.data = [{
      id: 1,
      val: Math.random()
    }, {
      id: 2,
      val: Math.random()
    }, {
      id: 3,
      val: Math.random()
    }, ...]

    this.renderItem = this.renderItem.bind(this)
  }

  renderItem ({index, isScrolling}) {
    const item = this.data[index]
    return (
      <div>#{index}, {item.val}</div>
    )
  }

  render () {
    return (
      <VirtualizedList
        itemCount={this.data.length}
        estimatedItemHeight={20}
        renderItem={this.renderItem}
      />
    )
  }
}

Check out the online demo here

Prop Types

|Property|Type|Default|Required?|Description| |:--:|:--:|:--:|:--:|:--:| |itemCount|Number||✓|The number of items you want to render| |renderItem|Function||✓|Responsible for rendering an item given its index and itself: ({index: number, isScrolling: boolean}):React.PropTypes.node| |overscanCount|Number|5||Number of extra buffer items to render above/below the visible items. Tweaking this can help reduce scroll flickering on certain browsers/devices| |estimatedItemHeight|Number|175||The estimated height of the list item element, which is used to estimate the total height of the list before all of its items have actually been measured| |className|String|''||Class names of the wrapper element| |onScroll|Function|() => {}||Callback invoked whenever the scroll offset changes within the inner scrollable region: ({scrollTop: number}):void| |loadMoreItems|Function|() => {}||Used to infinite scroll. Callback to be invoked when more items must be loaded| |onLoading|Function|() => null||Used to infinite scroll. The component will show when loading next page data| |onEnded|Function|() => null||Used to infinite scroll. The component will show when no more data to load| |hasMore|Boolean|false||Used to infinite scroll. Whether has more data to load| |height|Number|undefined||Height of the wrapper element. If useWindow is false and scrollableTarget is undefined, the wrapper element will be the scrollable target| |useWindow|Boolean|true||Whether to set the window to scrollable target | |scrollableTarget|String|undefined||Set the scrollable target, whose value is used to document.getElementById. window is the default scrollable target, so if you want to change it, you need to set useWindow to false and dont set the height prop | |noContentRenderer|Function|() => null||Callback used to render placeholder content when itemCount is 0|

Development

git clone [email protected]:dwqs/react-virtual-list.git

cd react-virtual-list

npm i 

npm run dev

LICENSE

This repo is released under the MIT