All Projects → developerdizzle → React Virtual List

developerdizzle / React Virtual List

Licence: mit
Super simple virtualized list React component

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Virtual List

Fast React Server
[DEPRECATED] Use last versions of React and Node.js for better performance
Stars: ✭ 139 (-76.72%)
Mutual labels:  performance, render
Listpool
Optimized allocation free implementation of IList using ArrayPool.
Stars: ✭ 25 (-95.81%)
Mutual labels:  list, performance
Fast React Render
[DEPRECATED] Use last versions of React and Node.js for better performance
Stars: ✭ 102 (-82.91%)
Mutual labels:  performance, render
Why Did You Render
why-did-you-render by Welldone Software monkey patches React to notify you about potentially avoidable re-renders. (Works with React Native as well.)
Stars: ✭ 7,695 (+1188.94%)
Mutual labels:  performance, render
Jxpagelistview
高仿闲鱼、转转、京东、中央天气预报等主流APP列表底部分页滚动视图
Stars: ✭ 377 (-36.85%)
Mutual labels:  list, scroll
Vue List Scroller
Simple and easy to use Vue.js component for efficient rendering large lists
Stars: ✭ 65 (-89.11%)
Mutual labels:  list, scroll
React Debounce Render
A React higher order component to debounce the rendering of your React components
Stars: ✭ 150 (-74.87%)
Mutual labels:  performance, render
React Virtualized
React components for efficiently rendering large lists and tabular data
Stars: ✭ 22,963 (+3746.4%)
Mutual labels:  list, performance
vue-virtual-stream
Simple vue-virtualized package for Vue.js
Stars: ✭ 16 (-97.32%)
Mutual labels:  list, virtual
Web Launch Checklist
📋 A simple website launch checklist to keep track of the most important enrichment possibilities for a website.
Stars: ✭ 214 (-64.15%)
Mutual labels:  list, performance
React Gridlist
A virtual-scrolling GridList component based on CSS Grids
Stars: ✭ 394 (-34%)
Mutual labels:  list, virtual
Vue Virtual Collection
Vue component for efficiently rendering large collection data
Stars: ✭ 506 (-15.24%)
Mutual labels:  performance, scroll
Dryioc
DryIoc is fast, small, full-featured IoC Container for .NET
Stars: ✭ 555 (-7.04%)
Mutual labels:  performance
React Scrollbars Custom
The best React custom scrollbars component
Stars: ✭ 576 (-3.52%)
Mutual labels:  scroll
Bloom
🌸 HTTP REST API caching middleware, to be used between load balancers and REST API workers.
Stars: ✭ 553 (-7.37%)
Mutual labels:  performance
Data Science With Ruby
Practical Data Science with Ruby based tools.
Stars: ✭ 549 (-8.04%)
Mutual labels:  list
Recyclerview Fastscroller
A fully customizable Fast Scroller for the RecyclerView in Android, written in Kotlin
Stars: ✭ 585 (-2.01%)
Mutual labels:  scroll
Chillout
Reduce CPU usage by non-blocking async loop and psychologically speed up in JavaScript
Stars: ✭ 565 (-5.36%)
Mutual labels:  performance
Automon
Automon combines the power of AOP (AspectJ) with monitoring or logging tools you already use to declaratively monitor your Java code, the JDK, and 3rd party libraries.
Stars: ✭ 548 (-8.21%)
Mutual labels:  performance
Awesome Honeypots
an awesome list of honeypot resources
Stars: ✭ 5,528 (+825.96%)
Mutual labels:  list

react-virtual-list Build Status npm bundle size (minified + gzip)

Super simple virtualized list higher-order component for React version ^15.0.0 || ^16.0.0.

Check out the demo here

react-virtual-list allows you to display a large list of fixed-height items, while only rendering the items visible on the screen. This allows a large list to be rendered with much fewer DOM elements.

Some other benefits:

  • One dependency (and it's prop-types)
  • Small!
  • Performant - demo page almost always stays over 60fps http://i.imgur.com/CHVCK9x.png
  • Keeps your components separate - as a higher-order component
  • Gives you control - doesn't force any particular markup, but gives you the necessary styles and data to use.

Legacy

If you're looking for documentation on version 1, supporting React ~0.13.x, it's here.

Installation

You can use npm to install react-virtual-list.

> npm install react-virtual-list --save

Usage

The ./lib/VirtualList.js module exports a single, ES5-compatible, CommonJS-accessible, component factory.

import VirtualList from 'react-virtual-list';

Your inner list component uses the virtual property to render the visible items, and set a style to set the overall list height and padding.

const MyList = ({
  virtual,
  itemHeight,
}) => (
  <ul style={virtual.style}>
    {virtual.items.map(item => (
      <li key={`item_${item.id}`} style={{height: itemHeight}}>
        Lorem ipsum dolor sit amet
      </li>
    ))}
  </ul>
);

Note: You should set keys on your list items.

Create the virtualized component.

const MyVirtualList = VirtualList()(MyList);

Write the JSX for the virtualized component with the necessary properties.

<MyVirtualList
  items={myBigListOfItems}
  itemHeight={100}
/>

Options

Options are used before the virtualized component can be created. This means that if you need to change an option after the initial render, you will need to recreate the virtualized component.

const options = {
  container: this.refs.container, // use this scrollable element as a container
  initialState: {
    firstItemIndex: 0, // show first ten items
    lastItemIndex: 9,  // during initial render
  },
};

const MyVirtualList = VirtualList(options)(MyList);
Name Type Default Description
container DOM Element window Scrollable element that contains the list. Use this if you have a list inside an element with overflow: scroll.
initialState object - An object with firstItemIndex and lastItemIndex properties, which represent array indexes of items (see below). These are used to calculate the visible items before the component is mounted. Useful for server-side rendering.

Properties

These properties and any others set on your virtual component, such as className, will be passed down to the inner component.

Name Type Default Description
items Array - Full array of list items. Only the visible subset of these will be rendered.
itemHeight Number - Height in pixels of a single item. You must have a CSS rule that sets the height of each list item to this value.
itemBuffer Number 0 Number of items that should be rendered before and after the visible viewport. Try using this if you have a complex list that suffers from a bit of lag when scrolling.

Mapping

VirtualList allows a second, optional, parameter, named mapVirtualToProps, which functions similarly to Redux's mapStateToProps. This function can be provided to change the properties passed to MyList. Its arguments are:

Name Description
props Includes all properties passed to MyVirtualList
state Includes firstItemIndex and lastItemIndex; array indexes of the visible bounds of items

The default mapVirtualToProps can be found here.

Example Usage

Check out demo/src/app.js and demo/src/ConfigurableExample.js for the example used in the demo.

Tests

Use npm test to run the tests using Jest. Not everything is currently tested yet!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].