react-window vs react-virtualized vs react-infinite-scroll-component vs react-list
Reactのスクロールライブラリ
react-windowreact-virtualizedreact-infinite-scroll-componentreact-list類似パッケージ:
Reactのスクロールライブラリ

これらのライブラリは、Reactアプリケーションにおけるスクロール機能を効率的に実装するためのツールです。無限スクロールや大規模なリストの表示を最適化し、パフォーマンスを向上させることができます。特に、データが大量にある場合に、ユーザー体験を損なうことなくスムーズな操作を実現します。

npmのダウンロードトレンド
3 年
GitHub Starsランキング
統計詳細
パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-window3,822,64216,986206 kB11ヶ月前MIT
react-virtualized1,307,92927,0362.24 MB110ヶ月前MIT
react-infinite-scroll-component853,8343,045169 kB19812時間前MIT
react-list397,7471,97434.9 kB711年前MIT
機能比較: react-window vs react-virtualized vs react-infinite-scroll-component vs react-list

パフォーマンス最適化

  • react-window:

    軽量な仮想化ライブラリで、必要なアイテムのみを描画します。シンプルなAPIで、パフォーマンスを重視したアプリケーションに適しています。

  • react-virtualized:

    仮想化技術を使用して、表示されているアイテムのみをレンダリングします。これにより、大規模なデータセットでもスムーズなスクロールを実現します。

  • react-infinite-scroll-component:

    無限スクロールの実装に特化しており、ユーザーがスクロールするたびに新しいデータを効率的にロードします。これにより、初期ロード時のデータ量を減らし、パフォーマンスを向上させます。

  • react-list:

    アイテムの高さが均一である場合に、リストのレンダリングを最適化します。必要なアイテムのみを描画することで、メモリ使用量を削減し、パフォーマンスを向上させます。

使いやすさ

  • react-window:

    非常にシンプルなAPIを持ち、すぐに使えるため、初心者にも適しています。必要な機能だけを提供するため、学習曲線が緩やかです。

  • react-virtualized:

    多機能である一方、設定が複雑になることがありますが、ドキュメントが充実しており、学習コストを軽減できます。

  • react-infinite-scroll-component:

    シンプルなAPIを提供しており、無限スクロールの実装が容易です。特別な設定なしで、すぐに使い始めることができます。

  • react-list:

    基本的なリスト表示に特化しているため、使いやすく、簡単に実装できます。特に、アイテムの高さが均一な場合に効果を発揮します。

機能の柔軟性

  • react-window:

    必要最低限の機能を提供し、簡単にカスタマイズできます。特に、パフォーマンスを重視したアプリケーションに最適です。

  • react-virtualized:

    リスト、テーブル、グリッドなど、さまざまなコンポーネントを提供し、柔軟なデータ表示が可能です。

  • react-infinite-scroll-component:

    無限スクロールの機能を持ち、カスタマイズ可能なローディングインジケーターをサポートしています。

  • react-list:

    リストの表示に特化しており、シンプルな構造でカスタマイズが容易です。

メンテナンス性

  • react-window:

    軽量でシンプルな設計により、メンテナンスが容易で、必要な機能だけを提供します。

  • react-virtualized:

    多機能であるため、複雑な実装になることがありますが、ドキュメントが充実しており、メンテナンスがしやすいです。

  • react-infinite-scroll-component:

    シンプルな設計により、メンテナンスが容易です。無限スクロールの実装が簡単で、コードの可読性が高いです。

  • react-list:

    コードがシンプルで、リストの表示に特化しているため、メンテナンスが容易です。

学習曲線

  • react-window:

    非常にシンプルなAPIを持ち、学習曲線が緩やかで、初心者にも適しています。

  • react-virtualized:

    多機能であるため、学習曲線はやや急ですが、ドキュメントが充実しているため、習得しやすいです。

  • react-infinite-scroll-component:

    シンプルなAPIを持ち、すぐに使い始めることができるため、学習曲線は緩やかです。

  • react-list:

    基本的なリスト表示に特化しているため、学習が容易です。

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

    軽量でシンプルな仮想化ライブラリを求める場合に適しています。特に、少量の機能で十分な場合や、パフォーマンスを重視する場合におすすめです。

  • react-virtualized:

    大規模なデータセットを扱う場合に最適です。リスト、テーブル、グリッドなど、さまざまなコンポーネントを提供し、仮想化によってパフォーマンスを向上させます。

  • react-infinite-scroll-component:

    無限スクロールを簡単に実装したい場合に最適です。シンプルなAPIで、スクロール位置に応じてデータを動的にロードすることができます。

  • react-list:

    リストの表示が主な目的で、パフォーマンスを重視する場合に適しています。特に、アイテムの高さが均一である場合に効果的です。

react-window のREADME

react-window

react-window is a component library that helps render large lists of data quickly and without the performance problems that often go along with rendering a lot of data. It's used in a lot of places, from React DevTools to the Replay browser.

Support

If you like this project there are several ways to support it:

The following wonderful companies and individuals have sponsored react-window:

Installation

Begin by installing the library from NPM:

npm install react-window

TypeScript types

TypeScript definitions are included within the published dist folder

Documentation

Documentation for this project is available at react-window.vercel.app; version 1.x documentation can be found at react-window-v1.vercel.app.

List

Required props

NameDescription
rowComponent

React component responsible for rendering a row.

This component will receive an index and style prop by default. Additionally it will receive prop values passed to rowProps.

ℹ️ The prop types for this component are exported as RowComponentProps

rowCount

Number of items to be rendered in the list.

rowHeight

Row height; the following formats are supported:

  • number of pixels (number)
  • percentage of the grid's current height (string)
  • function that returns the row height (in pixels) given an index and cellProps
  • dynamic row height cache returned by the useDynamicRowHeight hook

⚠️ Dynamic row heights are not as efficient as predetermined sizes. It's recommended to provide your own height values if they can be determined ahead of time.

rowProps

Additional props to be passed to the row-rendering component. List will automatically re-render rows when values in this object change.

⚠️ This object must not contain ariaAttributes, index, or style props.

Optional props

NameDescription
className

CSS class name.

style

Optional CSS properties. The list of rows will fill the height defined by this style.

children

Additional content to be rendered within the list (above cells). This property can be used to render things like overlays or tooltips.

defaultHeight

Default height of list for initial render. This value is important for server rendering.

listRef

Ref used to interact with this component's imperative API.

This API has imperative methods for scrolling and a getter for the outermost DOM element.

ℹ️ The useListRef and useListCallbackRef hooks are exported for convenience use in TypeScript projects.

onResize

Callback notified when the List's outermost HTMLElement resizes. This may be used to (re)scroll a row into view.

onRowsRendered

Callback notified when the range of visible rows changes.

overscanCount

How many additional rows to render outside of the visible area. This can reduce visual flickering near the edges of a list when scrolling.

tagName

Can be used to override the root HTML element rendered by the List component. The default value is "div", meaning that List renders an HTMLDivElement as its root.

⚠️ In most use cases the default ARIA roles are sufficient and this prop is not needed.

Grid

Required props

NameDescription
cellComponent

React component responsible for rendering a cell.

This component will receive an index and style prop by default. Additionally it will receive prop values passed to cellProps.

ℹ️ The prop types for this component are exported as CellComponentProps

cellProps

Additional props to be passed to the cell-rendering component. Grid will automatically re-render cells when values in this object change.

⚠️ This object must not contain ariaAttributes, columnIndex, rowIndex, or style props.

columnCount

Number of columns to be rendered in the grid.

columnWidth

Column width; the following formats are supported:

  • number of pixels (number)
  • percentage of the grid's current width (string)
  • function that returns the row width (in pixels) given an index and cellProps
rowCount

Number of rows to be rendered in the grid.

rowHeight

Row height; the following formats are supported:

  • number of pixels (number)
  • percentage of the grid's current height (string)
  • function that returns the row height (in pixels) given an index and cellProps

Optional props

NameDescription
className

CSS class name.

dir

Corresponds to the HTML dir attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir

style

Optional CSS properties. The grid of cells will fill the height and width defined by this style.

children

Additional content to be rendered within the grid (above cells). This property can be used to render things like overlays or tooltips.

defaultHeight

Default height of grid for initial render. This value is important for server rendering.

defaultWidth

Default width of grid for initial render. This value is important for server rendering.

gridRef

Ref used to interact with this component's imperative API.

This API has imperative methods for scrolling and a getter for the outermost DOM element.

ℹ️ The useGridRef and useGridCallbackRef hooks are exported for convenience use in TypeScript projects.

onCellsRendered

Callback notified when the range of rendered cells changes.

onResize

Callback notified when the Grid's outermost HTMLElement resizes. This may be used to (re)scroll a cell into view.

overscanCount

How many additional rows/columns to render outside of the visible area. This can reduce visual flickering near the edges of a grid when scrolling.

tagName

Can be used to override the root HTML element rendered by the List component. The default value is "div", meaning that List renders an HTMLDivElement as its root.

⚠️ In most use cases the default ARIA roles are sufficient and this prop is not needed.