react-virtualized vs react-list vs react-tiny-virtual-list vs react-infinite vs react-window
無限スクロールと仮想化リスト
react-virtualizedreact-listreact-tiny-virtual-listreact-infinitereact-window類似パッケージ:

無限スクロールと仮想化リスト

無限スクロールと仮想化リストは、長いリストやデータセットを効率的に表示するための技術です。これらの技術は、ユーザーがリストをスクロールする際に、必要なデータのみをレンダリングすることでパフォーマンスを向上させ、メモリ使用量を削減します。無限スクロールは、ユーザーがスクロールするにつれて新しいアイテムを自動的に読み込む方法で、仮想化リストは表示領域に見えるアイテムのみをレンダリングします。これにより、大規模なデータセットを扱う際の遅延やクラッシュを防ぎます。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-virtualized1,703,27527,0802.24 MB11年前MIT
react-list507,3611,97434.9 kB711年前MIT
react-tiny-virtual-list115,6712,497-548年前MIT
react-infinite11,1162,687243 kB102-BSD-3-Clause
react-window017,113209 kB125日前MIT

機能比較: react-virtualized vs react-list vs react-tiny-virtual-list vs react-infinite vs react-window

無限スクロール

  • react-virtualized:

    react-virtualizedは、無限スクロールをサポートする高度な仮想化ライブラリです。リスト、テーブル、グリッドなど、さまざまなコンポーネントの無限スクロールを実装できます。特に、大規模なデータセットを効率的に処理できるため、エンタープライズアプリケーションに適しています。

  • react-list:

    react-listは、無限スクロールと仮想化の両方をサポートする柔軟なコンポーネントです。無限スクロール機能はありますが、特に仮想化に重点を置いているため、アイテムの高さが一定でない場合や、複雑なリスト構造を扱う必要がある場合に適しています。

  • react-tiny-virtual-list:

    react-tiny-virtual-listは、無限スクロール機能は提供していませんが、仮想化リストを効率的にレンダリングするためのコンポーネントです。無限スクロールと組み合わせて使用することができますが、ライブラリ自体には無限スクロール機能はありません。

  • react-infinite:

    react-infiniteは、スクロール位置に応じてアイテムを動的に読み込む無限スクロール機能を提供します。特に、ページネーションやAPIからのデータ取得を簡単に統合できるため、無限スクロールが必要なプロジェクトに適しています。

  • react-window:

    react-windowは、無限スクロールをサポートする軽量な仮想化ライブラリです。リストやグリッドの無限スクロールを簡単に実装でき、特にパフォーマンスを重視したアプリケーションに適しています。シンプルなAPIで使いやすく、リソースを効率的に使用したいプロジェクトに最適です。

仮想化

  • react-virtualized:

    react-virtualizedは、リスト、テーブル、グリッドなど、さまざまなコンポーネントの仮想化を提供する包括的なライブラリです。高度な機能とカスタマイズ性を備えており、大規模なデータセットを効率的に処理できます。特に、複雑なリストやテーブルを扱う必要があるエンタープライズアプリケーションに適しています。

  • react-list:

    react-listは、リストの仮想化と無限スクロールの両方をサポートする柔軟なコンポーネントです。仮想化に関しては、高度な制御を提供し、アイテムの高さが一定でない場合や、複雑なリスト構造を扱う必要がある場合に特に効果的です。

  • react-tiny-virtual-list:

    react-tiny-virtual-listは、仮想化リストを効率的にレンダリングするためのコンポーネントです。アイテムの高さが一定でない場合でも対応しており、シンプルなAPIで使いやすく、特にパフォーマンスが重要なアプリケーションに適しています。

  • react-infinite:

    react-infiniteは、無限スクロールに特化したライブラリで、仮想化機能は提供していません。スクロール位置に応じてアイテムを動的に読み込むことに重点を置いています。

  • react-window:

    react-windowは、リストやグリッドの仮想化を簡単に実装できるライブラリです。シンプルなAPIと小さなバンドルサイズが特徴で、特にパフォーマンスを重視したアプリケーションに適しています。仮想化機能を提供しつつ、複雑さを抑えた設計になっています。

バンドルサイズ

  • react-virtualized:

    react-virtualizedは、機能が豊富なためバンドルサイズは大きくなりますが、複雑なリストやテーブルを扱う必要がある場合にはその価値があります。

  • react-list:

    react-listは、仮想化と無限スクロールの両方をサポートするため、バンドルサイズはやや大きくなりますが、柔軟性と機能性を考慮すれば許容範囲です。

  • react-tiny-virtual-list:

    react-tiny-virtual-listは、非常に小さなバンドルサイズが特徴で、パフォーマンスに優れた仮想リストを提供します。特に、リソースを節約したいアプリケーションに最適です。

  • react-infinite:

    react-infiniteは、比較的小さなバンドルサイズを持つライブラリで、無限スクロール機能を実装する際にパフォーマンスに与える影響は少ないです。

  • react-window:

    react-windowは、react-virtualizedの軽量版で、バンドルサイズが小さく、パフォーマンスを重視したアプリケーションに適しています。仮想化機能を提供しつつ、リソースを効率的に使用することができます。

使いやすさ

  • react-virtualized:

    react-virtualizedは、機能が豊富ですが、設定が複雑なため、初心者にはやや難しいかもしれません。特に、カスタマイズ性が高い分、使いこなすまでに時間がかかることがあります。

  • react-list:

    react-listは、柔軟性が高く、カスタマイズ可能ですが、仮想化と無限スクロールの両方をサポートしているため、少し複雑に感じることがあります。

  • react-tiny-virtual-list:

    react-tiny-virtual-listは、シンプルなAPIと軽量な設計が特徴で、使いやすさに優れています。特に、パフォーマンスを重視したアプリケーションに簡単に統合できます。

  • react-infinite:

    react-infiniteは、シンプルなAPIを提供しており、無限スクロールを簡単に実装できます。特に、ドキュメントが充実しているため、導入が容易です。

  • react-window:

    react-windowは、シンプルなAPIと軽量な設計が特徴で、使いやすさに優れています。特に、仮想化機能を簡単に実装できるため、リソースを効率的に使用したいプロジェクトに最適です。

選び方: react-virtualized vs react-list vs react-tiny-virtual-list vs react-infinite vs react-window

  • react-virtualized:

    react-virtualizedは、リスト、テーブル、グリッドなど、さまざまなコンポーネントの仮想化を提供する包括的なライブラリです。高度な機能とカスタマイズ性を備えており、大規模なデータセットを効率的に処理できます。特に、複雑なリストやテーブルを扱う必要があるエンタープライズアプリケーションに適していますが、学習曲線がやや急なため、初心者には少し難しいかもしれません。

  • react-list:

    react-listは、リストの仮想化と無限スクロールの両方をサポートする柔軟なコンポーネントです。リストのアイテムを効率的にレンダリングするための高度な制御を提供し、カスタマイズ可能なレンダリングロジックを持っています。特に、アイテムの高さが一定でない場合や、複雑なリスト構造を扱う必要がある場合に適しています。

  • react-tiny-virtual-list:

    react-tiny-virtual-listは、軽量で高速な仮想リストコンポーネントです。シンプルなAPIと小さなバンドルサイズが特徴で、特にパフォーマンスが重要なアプリケーションに適しています。アイテムの高さが一定でない場合でも対応しており、簡単に統合できるため、リソースを節約しながらリストを表示したいプロジェクトに最適です。

  • react-infinite:

    react-infiniteは、無限スクロールを実装するためのシンプルで使いやすいライブラリです。スクロール位置に基づいてアイテムを動的に読み込む機能を提供します。特に、ページネーションやAPIからのデータ取得を簡単に統合できるため、無限スクロールが必要なプロジェクトに適しています。

  • react-window:

    react-windowは、react-virtualizedの軽量版で、リストやグリッドの仮想化を簡単に実装できるライブラリです。シンプルなAPIと小さなバンドルサイズが特徴で、特にパフォーマンスを重視したアプリケーションに適しています。複雑さを抑えながら仮想化機能を提供するため、リソースを効率的に使用したいプロジェクトに最適です。

react-virtualized のREADME

React virtualized

React components for efficiently rendering large lists and tabular data. Check out the demo for some examples.

If you like this project, 🎉 become a sponsor or ☕ buy me a coffee

Sponsors

The following wonderful companies have sponsored react-virtualized:

Learn more about becoming a sponsor!

A word about react-window

If you're considering adding react-virtualized to a project, take a look at react-window as a possible lighter-weight alternative. Learn more about how the two libraries compare here.

Getting started

Install react-virtualized using npm.

npm install react-virtualized --save

ES6, CommonJS, and UMD builds are available with each distribution. For example:

// Most of react-virtualized's styles are functional (eg position, size).
// Functional styles are applied directly to DOM elements.
// The Table component ships with a few presentational styles as well.
// They are optional, but if you want them you will need to also import the CSS file.
// This only needs to be done once; probably during your application's bootstrapping process.
import 'react-virtualized/styles.css';

// You can import any component you want as a named export from 'react-virtualized', eg
import {Column, Table} from 'react-virtualized';

// But if you only use a few react-virtualized components,
// And you're concerned about increasing your application's bundle size,
// You can directly import only the components you need, like so:
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
import List from 'react-virtualized/dist/commonjs/List';

Note webpack 4 makes this optimization itself, see the documentation.

If the above syntax looks too cumbersome, or you import react-virtualized components from a lot of places, you can also configure a Webpack alias. For example:

// Partial webpack.config.js
{
  alias: {
    'react-virtualized/List': 'react-virtualized/dist/es/List',
  },
  ...rest
}

Then you can just import like so:

import List from 'react-virtualized/List';

// Now you can use <List {...props} />

You can also use a global-friendly UMD build:

<link rel="stylesheet" href="path-to-react-virtualized/styles.css" />
<script src="path-to-react-virtualized/dist/umd/react-virtualized.js"></script>

Now you're ready to start using the components. You can learn more about which components react-virtualized has to offer below.

Dependencies

React Virtualized has very few dependencies and most are managed by NPM automatically. However the following peer dependencies must be specified by your project in order to avoid version conflicts: react, react-dom. NPM will not automatically install these for you but it will show you a warning message with instructions on how to install them.

Pure Components

By default all react-virtualized components use shallowCompare to avoid re-rendering unless props or state has changed. This occasionally confuses users when a collection's data changes (eg ['a','b','c'] => ['d','e','f']) but props do not (eg array.length).

The solution to this is to let react-virtualized know that something external has changed. This can be done a couple of different ways.

Pass-thru props

The shallowCompare method will detect changes to any props, even if they aren't declared as propTypes. This means you can also pass through additional properties that affect cell rendering to ensure changes are detected. For example, if you're using List to render a list of items that may be re-sorted after initial render- react-virtualized would not normally detect the sort operation because none of the properties it deals with change. However you can pass through the additional sort property to trigger a re-render. For example:

<List {...listProps} sortBy={sortBy} />
Public methods

Grid and Collection components can be forcefully re-rendered using forceUpdate. For Table and List, you'll need to call forceUpdateGrid to ensure that the inner Grid is also updated. For MultiGrid, you'll need to call forceUpdateGrids to ensure that the inner Grids are updated.

Documentation

API documentation available here.

There are also a couple of how-to guides:

Examples

Examples for each component can be seen in the documentation.

Here are some online demos of each component:

And here are some "recipe" type demos:

Supported Browsers

react-virtualized aims to support all evergreen browsers and recent mobile browsers for iOS and Android. IE 9+ is also supported (although IE 9 will require some user-defined, custom CSS since flexbox layout is not supported).

If you find a browser-specific problem, please report it along with a repro case. The easiest way to do this is probably by forking this Plunker.

Friends

Here are some great components built on top of react-virtualized:

  • react-infinite-calendar: Infinite scrolling date-picker with localization, themes, keyboard support, and more
  • react-sortable-hoc: Higher-order components to turn any list into an animated, touch-friendly, sortable list
  • react-sortable-tree: Drag-and-drop sortable representation of hierarchical data
  • react-virtualized-checkbox: Checkbox group component with virtualization for large number of options
  • react-virtualized-select: Drop-down menu for React with windowing to support large numbers of options.
  • react-virtualized-tree: A reactive tree component that aims to render large sets of tree structured data in an elegant and performant way
  • react-timeline-9000: A calendar timeline component that is capable of displaying and interacting with a large number of items

Contributions

Use GitHub issues for requests.

I actively welcome pull requests; learn how to contribute.

Changelog

Changes are tracked in the changelog.

License

react-virtualized is available under the MIT License.