Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dwqs/react-virtual-list

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dwqs/react-virtual-list

A tiny virtualization list component, supports variable height

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

PropertyTypeDefaultRequired?Description
itemCountNumberThe number of items you want to render
renderItemFunctionResponsible for rendering an item given its index and itself: ({index: number, isScrolling: boolean}):React.PropTypes.node
overscanCountNumber5Number of extra buffer items to render above/below the visible items. Tweaking this can help reduce scroll flickering on certain browsers/devices
estimatedItemHeightNumber175The 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
classNameString''Class names of the wrapper element
onScrollFunction() => {}Callback invoked whenever the scroll offset changes within the inner scrollable region: ({scrollTop: number}):void
loadMoreItemsFunction() => {}Used to infinite scroll. Callback to be invoked when more items must be loaded
onLoadingFunction() => nullUsed to infinite scroll. The component will show when loading next page data
onEndedFunction() => nullUsed to infinite scroll. The component will show when no more data to load
hasMoreBooleanfalseUsed to infinite scroll. Whether has more data to load
heightNumberundefinedHeight of the wrapper element. If useWindow is false and scrollableTarget is undefined, the wrapper element will be the scrollable target
useWindowBooleantrueWhether to set the window to scrollable target
scrollableTargetStringundefinedSet 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
noContentRendererFunction() => nullCallback used to render placeholder content when itemCount is 0

Development

git clone git@github.com:dwqs/react-virtual-list.git

cd react-virtual-list

npm i 

npm run dev

LICENSE

This repo is released under the MIT

Keywords

FAQs

Package last updated on 18 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc