react-window vs react-virtualized vs react-virtual
仮想化ライブラリ
react-windowreact-virtualizedreact-virtual類似パッケージ:
仮想化ライブラリ

仮想化ライブラリは、大量のデータを効率的に表示するために使用されるツールです。これらのライブラリは、画面に表示される要素のみをレンダリングし、スクロール時に必要に応じて新しい要素を動的に追加することで、パフォーマンスを最適化します。これにより、特に長いリストやテーブルを扱う際に、ユーザーインターフェースの応答性が向上します。

npmのダウンロードトレンド
3 年
GitHub Starsランキング
統計詳細
パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-window4,093,17816,989206 kB21ヶ月前MIT
react-virtualized1,391,53527,0372.24 MB11年前MIT
react-virtual457,3586,546158 kB98-MIT
機能比較: react-window vs react-virtualized vs react-virtual

パフォーマンス

  • react-window:

    react-windowは、軽量で高性能な仮想化を提供し、特に大規模なリストに対して優れたパフォーマンスを発揮します。必要な機能に絞っているため、オーバーヘッドが少なくなっています。

  • react-virtualized:

    react-virtualizedは、複雑なデータセットを扱う際に最適化されており、効率的なレンダリングを提供します。多くの機能を持つため、パフォーマンスを最大限に引き出すための設定が可能です。

  • react-virtual:

    react-virtualは、必要な要素のみをレンダリングすることで、メモリ使用量を最小限に抑え、パフォーマンスを向上させます。特に、少ない設定でスムーズなスクロールを実現します。

機能性

  • react-window:

    react-windowは、基本的なリストとグリッドの仮想化機能を提供し、シンプルで使いやすい設計になっています。機能は限定的ですが、パフォーマンスを重視しています。

  • react-virtualized:

    react-virtualizedは、リスト、グリッド、テーブルなど、さまざまなデータ表示に対応した多機能なライブラリです。多くの組み込みコンポーネントを持ち、柔軟にカスタマイズできます。

  • react-virtual:

    react-virtualは、基本的な仮想化機能を提供し、シンプルなリスト表示に適しています。カスタマイズ性は限られていますが、簡単に導入できます。

学習曲線

  • react-window:

    react-windowは、シンプルな設計のおかげで、比較的簡単に学習できます。基本的な機能に特化しているため、すぐに実装できます。

  • react-virtualized:

    react-virtualizedは、多機能であるため、学習曲線がやや急です。多くのオプションや設定があるため、使いこなすには時間がかかるかもしれません。

  • react-virtual:

    react-virtualは、シンプルなAPIを持ち、学習曲線が緩やかです。初心者でも簡単に導入できるため、すぐに使い始めることができます。

カスタマイズ性

  • react-window:

    react-windowは、基本的なカスタマイズが可能ですが、react-virtualizedほどの柔軟性はありません。シンプルなニーズには適しています。

  • react-virtualized:

    react-virtualizedは、高度なカスタマイズが可能で、さまざまなデータ表示に対応できます。複雑な要件に対しても柔軟に対応できます。

  • react-virtual:

    react-virtualは、カスタマイズ性が限られていますが、シンプルなニーズには適しています。特定の要件に応じた調整は難しいかもしれません。

使用シナリオ

  • react-window:

    react-windowは、シンプルなリストやグリッド表示に最適で、パフォーマンスを重視したアプリケーションに適しています。

  • react-virtualized:

    react-virtualizedは、大規模なデータセットや複雑なリスト表示に最適です。多機能なため、さまざまなシナリオに対応できます。

  • react-virtual:

    react-virtualは、小規模なリストやシンプルなデータ表示に最適です。特に、軽量なアプリケーションでの使用に適しています。

選び方: react-window vs react-virtualized vs react-virtual
  • react-window:

    react-windowは、react-virtualizedの軽量版で、パフォーマンスを重視した設計になっています。基本的な機能を必要とし、シンプルなリストやグリッドを扱う場合に最適です。

  • react-virtualized:

    react-virtualizedは、より多機能で、複雑なリストやテーブルの表示に最適です。多くの組み込みコンポーネントや機能を提供しており、カスタマイズ性が高いですが、学習曲線がやや急です。

  • react-virtual:

    react-virtualは、シンプルで軽量な仮想化ソリューションを提供します。特に、最小限の設定で簡単に使用したい場合や、特定の機能が不要な場合に適しています。

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.