react-virtualized vs react-infinite vs react-infinite-scroll-component vs react-window
無限スクロールライブラリ
react-virtualizedreact-infinitereact-infinite-scroll-componentreact-window類似パッケージ:

無限スクロールライブラリ

無限スクロールライブラリは、ユーザーがスクロールすることでコンテンツを動的に読み込む機能を提供します。これにより、大量のデータを効率的に表示し、ユーザーエクスペリエンスを向上させることができます。これらのライブラリは、パフォーマンスを最適化し、メモリ使用量を削減し、スムーズなスクロール体験を実現します。

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

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-virtualized1,723,75827,0671.31 MB18日前MIT
react-infinite14,9762,682243 kB101-BSD-3-Clause
react-infinite-scroll-component03,091217 kB1385ヶ月前MIT
react-window017,200417 kB03分前MIT

機能比較: react-virtualized vs react-infinite vs react-infinite-scroll-component vs react-window

パフォーマンス最適化

  • react-virtualized:

    react-virtualizedは、仮想化技術を使用して、表示されているアイテムのみをレンダリングし、パフォーマンスを大幅に向上させます。特に、大量のデータを扱う場合に効果的です。

  • react-infinite:

    react-infiniteは、シンプルな無限スクロールを提供し、必要なデータのみをロードすることでパフォーマンスを最適化します。

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、スクロールイベントをトリガーにしてデータを追加するため、必要なデータを効率的に取得し、パフォーマンスを向上させます。

  • react-window:

    react-windowは、軽量でシンプルな仮想化を提供し、パフォーマンスを最適化しつつ、必要なアイテムのみを表示します。

使いやすさ

  • react-virtualized:

    react-virtualizedは、機能が豊富ですが、学習曲線がやや急であるため、ある程度の経験が必要です。

  • react-infinite:

    react-infiniteは、シンプルなAPIを提供しており、初心者でも簡単に無限スクロールを実装できます。

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、カスタマイズが容易で、柔軟性が高いため、さまざまなプロジェクトに適用できます。

  • react-window:

    react-windowは、シンプルなAPIを持ち、使いやすさを重視しているため、初心者にも適しています。

機能の柔軟性

  • react-virtualized:

    react-virtualizedは、リストやテーブルの仮想化に特化しており、複雑なデータ構造にも対応可能です。

  • react-infinite:

    react-infiniteは、基本的な無限スクロール機能を提供しますが、カスタマイズは限られています。

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、さまざまなカスタマイズオプションを提供し、特定のニーズに応じて柔軟に対応できます。

  • react-window:

    react-windowは、シンプルなリストやグリッド表示に特化しており、必要な機能に絞った設計がされています。

メンテナンス性

  • react-virtualized:

    react-virtualizedは、機能が多いため、メンテナンスには注意が必要ですが、コミュニティが活発です。

  • react-infinite:

    react-infiniteは、シンプルな設計のため、メンテナンスが容易です。

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、活発にメンテナンスされており、最新のReactバージョンに対応しています。

  • react-window:

    react-windowは、軽量でシンプルな設計のため、メンテナンスが容易で、変更が少ないです。

学習曲線

  • react-virtualized:

    react-virtualizedは、機能が豊富なため、学習曲線が急ですが、習得すれば強力なツールになります。

  • react-infinite:

    react-infiniteは、シンプルなAPIのため、学習曲線が緩やかです。

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、使いやすさと柔軟性を兼ね備えており、比較的短期間で習得できます。

  • react-window:

    react-windowは、シンプルな設計のため、学習曲線が緩やかで、すぐに使い始めることができます。

選び方: react-virtualized vs react-infinite vs react-infinite-scroll-component vs react-window

  • react-virtualized:

    react-virtualizedは、非常に大きなリストやテーブルを扱う場合に最適です。パフォーマンスを重視し、仮想化を利用して表示するアイテム数を制限したい場合に選択すべきです。

  • react-infinite:

    react-infiniteは、シンプルな無限スクロールを実装したい場合に最適です。特に、データの追加が少ない場合や、基本的な機能だけで十分な場合に適しています。

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、簡単にカスタマイズ可能で、特に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 documentation for live 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.

Getting started

Install react-virtualized using npm.

npm install react-virtualized --save

ES module and CommonJS builds are included, along with TypeScript type definitions. 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';

The package is marked as side-effect free (other than its CSS), so bundlers will tree-shake any components you don't use.

TypeScript types are exported for each component's props (e.g. ListProps, GridProps, TableProps) along with the parameters passed to renderers (e.g. RowRendererParams, CellRendererParams, TableCellProps).

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 are wrapped in memo 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

This shallow comparison will detect changes to any props, even ones a component doesn't use. 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 components can be forcefully re-rendered by calling forceUpdate on their ref. 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

Documentation and live examples for every component are available at react-virtualized-docs.vercel.app.

Components:

CellMeasurer measures cells whose sizes aren't known ahead of time.

Grid, List, Masonry and Table can also be scrolled by the window (or another scrollable element) with the scrollElement prop.

Higher-order components:

[!NOTE] AutoSizer is no longer part of react-virtualized (as of version 10); it is available as the separate react-virtualized-auto-sizer package. See sizing components for how to use it with react-virtualized.

There are also a couple of how-to guides:

Examples

Here are some "recipe" type demos:

Supported Browsers

react-virtualized aims to support all evergreen browsers and recent mobile browsers for iOS and Android.

If you find a browser-specific problem, please report it along with a repro case (e.g. a CodeSandbox).

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.