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

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

npmのダウンロードトレンド
3 年
GitHub Starsランキング
統計詳細
パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-window3,613,11516,985206 kB11ヶ月前MIT
react-virtualized1,242,77827,0362.24 MB110ヶ月前MIT
react-infinite-scroll-component808,6873,045-2005年前MIT
react-infinite9,7892,692243 kB102-BSD-3-Clause
機能比較: react-window vs react-virtualized vs react-infinite-scroll-component vs react-infinite

パフォーマンス最適化

  • react-window:

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

  • react-virtualized:

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

  • react-infinite-scroll-component:

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

  • react-infinite:

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

使いやすさ

  • react-window:

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

  • react-virtualized:

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

  • react-infinite-scroll-component:

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

  • react-infinite:

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

機能の柔軟性

  • react-window:

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

  • react-virtualized:

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

  • react-infinite-scroll-component:

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

  • react-infinite:

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

メンテナンス性

  • react-window:

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

  • react-virtualized:

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

  • react-infinite-scroll-component:

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

  • react-infinite:

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

学習曲線

  • react-window:

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

  • react-virtualized:

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

  • react-infinite-scroll-component:

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

  • react-infinite:

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

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

    react-windowは、react-virtualizedの軽量版で、シンプルなAPIを提供します。軽量でありながら、高いパフォーマンスを求める場合に適しています。特に、リストやグリッドの表示に特化したい場合におすすめです。

  • react-virtualized:

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

  • react-infinite-scroll-component:

    react-infinite-scroll-componentは、簡単にカスタマイズ可能で、特にAPIからのデータ取得を行う場合に便利です。スクロールイベントの管理が容易で、柔軟性が求められるプロジェクトに適しています。

  • react-infinite:

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

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.