react-window vs react-virtualized vs react-window-infinite-loader vs react-list vs react-virtual vs react-infinite
React 无限滚动库
react-windowreact-virtualizedreact-window-infinite-loaderreact-listreact-virtualreact-infinite类似的npm包:

React 无限滚动库

这些库旨在优化和增强 React 应用程序中的列表和滚动体验,特别是在处理大量数据时。它们通过虚拟化和懒加载等技术,显著提高性能,减少渲染时间,并改善用户体验。选择合适的库可以帮助开发者高效地管理长列表,提升应用的响应速度和流畅度。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
react-window4,169,69917,128209 kB11 个月前MIT
react-virtualized1,354,08727,0822.24 MB11 年前MIT
react-window-infinite-loader532,82495223 kB02 个月前MIT
react-list402,3201,97434.9 kB711 年前MIT
react-virtual401,1896,760158 kB105-MIT
react-infinite7,6162,687243 kB102-BSD-3-Clause

功能对比: react-window vs react-virtualized vs react-window-infinite-loader vs react-list vs react-virtual vs react-infinite

性能优化

  • react-window:

    react-window 是 react-virtualized 的轻量级替代品,专注于基本的虚拟化功能,性能表现良好。

  • react-virtualized:

    react-virtualized 提供了多种虚拟化策略,支持复杂的列表和表格,性能优化非常全面。

  • react-window-infinite-loader:

    react-window-infinite-loader 在使用 react-window 的基础上,提供了无限加载的功能,优化了数据加载的性能。

  • react-list:

    react-list 提供了灵活的渲染选项,能够根据可见区域动态加载和卸载列表项,优化性能。

  • react-virtual:

    react-virtual 通过虚拟化技术显著减少 DOM 节点的数量,从而提高性能,适合大规模数据集。

  • react-infinite:

    react-infinite 通过简单的无限滚动实现,适合处理较小的数据集,性能优化相对基础。

易用性

  • react-window:

    react-window 的 API 简单明了,易于使用,适合快速开发。

  • react-virtualized:

    react-virtualized 功能丰富,但学习曲线相对陡峭,适合有经验的开发者。

  • react-window-infinite-loader:

    react-window-infinite-loader 结合了 react-window 的易用性和无限加载的功能,适合需要动态加载数据的场景。

  • react-list:

    react-list 的 API 灵活,支持多种自定义选项,适合中小型项目。

  • react-virtual:

    react-virtual 的 API 设计简洁,易于理解,适合需要高度自定义的开发者。

  • react-infinite:

    react-infinite 提供了简单的 API,易于上手,适合快速开发和原型设计。

功能丰富性

  • react-window:

    react-window 提供基本的虚拟化功能,适合简单使用场景。

  • react-virtualized:

    react-virtualized 提供了多种复杂的功能,如表格虚拟化和动态加载,功能非常丰富。

  • react-window-infinite-loader:

    react-window-infinite-loader 结合了无限加载和虚拟化的功能,适合复杂的应用场景。

  • react-list:

    react-list 支持动态数据和自定义渲染,功能相对丰富。

  • react-virtual:

    react-virtual 专注于虚拟化,功能简洁但强大。

  • react-infinite:

    react-infinite 提供基本的无限滚动功能,适合简单场景。

社区支持

  • react-window:

    react-window 的社区支持良好,文档简洁明了,易于使用。

  • react-virtualized:

    react-virtualized 拥有强大的社区支持和丰富的文档,适合大型项目。

  • react-window-infinite-loader:

    react-window-infinite-loader 作为 react-window 的扩展,享有良好的社区支持。

  • react-list:

    react-list 拥有活跃的社区,文档完善,支持较好。

  • react-virtual:

    react-virtual 社区逐渐壮大,文档清晰,支持逐步增加。

  • react-infinite:

    react-infinite 社区较小,更新频率较低,支持相对有限。

学习曲线

  • react-window:

    react-window 的学习曲线平缓,易于上手。

  • react-virtualized:

    react-virtualized 的学习曲线较陡,适合有经验的开发者。

  • react-window-infinite-loader:

    react-window-infinite-loader 的学习曲线与 react-window 相似,适合快速上手。

  • react-list:

    react-list 的学习曲线适中,适合有一定经验的开发者。

  • react-virtual:

    react-virtual 的学习曲线相对较低,适合需要灵活性的开发者。

  • react-infinite:

    react-infinite 的学习曲线平缓,适合初学者。

如何选择: react-window vs react-virtualized vs react-window-infinite-loader vs react-list vs react-virtual vs react-infinite

  • react-window:

    选择 react-window 如果你需要一个轻量级的替代方案,提供基本的虚拟化功能,适合简单的列表和表格。

  • react-virtualized:

    选择 react-virtualized 如果你需要一个功能丰富的虚拟化解决方案,支持复杂的列表和表格,适合大型应用程序。

  • react-window-infinite-loader:

    选择 react-window-infinite-loader 如果你需要与 react-window 结合使用的无限加载功能,适合需要动态加载数据的场景。

  • react-list:

    选择 react-list 如果你需要一个灵活的列表组件,支持动态数据和简单的自定义功能,适合中小型项目。

  • react-virtual:

    选择 react-virtual 如果你需要一个轻量级的虚拟化库,专注于性能和灵活性,适合需要高度自定义的场景。

  • react-infinite:

    选择 react-infinite 如果你需要一个简单易用的无限滚动解决方案,适合小型项目或快速原型开发。

react-window的README

react-window logo

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

FAQs

Frequently asked questions can be found here.

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

Renders data with many rows.

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

Renders data with many rows and columns.

ℹ️ Unlike List rows, Grid cell sizes must be known ahead of time. Either static sizes or something that can be derived (from the data in CellProps) without rendering.

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 column 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

Indicates the directionality of grid cells.

ℹ️ See HTML dir global attribute for more information.

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

Imperative Grid API.

ℹ️ 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.