react-virtualized vs vue-virtual-scroller vs ngx-virtual-scroller vs ngx-infinite-scroll vs react-infinite-scroll-component vs react-window
无限滚动和虚拟滚动库
react-virtualizedvue-virtual-scrollerngx-virtual-scrollerngx-infinite-scrollreact-infinite-scroll-componentreact-window类似的npm包:

无限滚动和虚拟滚动库

这些库用于实现无限滚动和虚拟滚动功能,帮助开发者在处理大量数据时提升性能和用户体验。无限滚动允许用户在滚动时动态加载更多内容,而虚拟滚动则通过只渲染可视区域内的元素来优化性能,减少内存占用和渲染时间。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
react-virtualized1,354,08727,0842.24 MB11 年前MIT
vue-virtual-scroller339,83110,632166 kB2496 天前MIT
ngx-virtual-scroller7,254985-1536 年前MIT
ngx-infinite-scroll01,25470.3 kB153 个月前MIT
react-infinite-scroll-component03,069169 kB2013 个月前MIT
react-window017,130209 kB21 个月前MIT

功能对比: react-virtualized vs vue-virtual-scroller vs ngx-virtual-scroller vs ngx-infinite-scroll vs react-infinite-scroll-component vs react-window

无限滚动

  • ngx-infinite-scroll:

    ngx-infinite-scroll提供简单的无限滚动功能,允许用户在滚动到页面底部时自动加载更多内容。它支持自定义加载指示器和触发条件,易于集成到Angular应用中。

  • react-infinite-scroll-component:

    react-infinite-scroll-component允许用户在滚动时自动加载更多数据,支持自定义加载逻辑和样式,适合快速构建无限滚动列表。

虚拟滚动

  • react-virtualized:

    react-virtualized提供强大的虚拟化功能,支持复杂的列表和表格,能够高效处理数千条数据,适合需要高性能渲染的应用。

  • vue-virtual-scroller:

    vue-virtual-scroller通过虚拟化技术优化Vue应用的渲染性能,适合处理大量数据,减少内存占用。

  • ngx-virtual-scroller:

    ngx-virtual-scroller通过只渲染可视区域内的元素来优化性能,适合处理大量数据的场景,减少DOM节点的数量,提高渲染效率。

  • react-window:

    react-window是一个轻量级的虚拟化库,适合简单的列表,提供基本的虚拟滚动功能,易于使用,适合小型项目。

性能优化

  • react-virtualized:

    react-virtualized通过虚拟化技术显著提高性能,支持复杂的布局和大量数据,能够动态计算可视区域,减少不必要的渲染。

  • react-window:

    react-window是一个轻量级的虚拟化解决方案,专注于性能,能够快速渲染大量数据,适合简单的列表和小型应用。

易用性

  • vue-virtual-scroller:

    vue-virtual-scroller提供直观的API,易于集成到Vue项目中,适合开发者快速实现虚拟滚动。

  • ngx-infinite-scroll:

    ngx-infinite-scroll易于集成和使用,适合快速开发,提供简单的API和丰富的文档支持。

  • react-infinite-scroll-component:

    react-infinite-scroll-component提供简单的API,易于上手,适合快速构建无限滚动功能。

社区支持

  • react-virtualized:

    react-virtualized拥有活跃的社区和丰富的文档,提供多种示例和最佳实践,适合开发者深入学习和使用。

  • ngx-virtual-scroller:

    ngx-virtual-scroller在Angular社区中受到广泛使用,提供良好的文档和支持,适合Angular开发者。

如何选择: react-virtualized vs vue-virtual-scroller vs ngx-virtual-scroller vs ngx-infinite-scroll vs react-infinite-scroll-component vs react-window

  • react-virtualized:

    选择react-virtualized如果你需要强大的虚拟化功能,支持复杂的列表和表格,适合处理大量数据的应用。

  • vue-virtual-scroller:

    选择vue-virtual-scroller如果你在使用Vue并需要高效的虚拟滚动解决方案,适合处理大量数据的场景。

  • ngx-virtual-scroller:

    选择ngx-virtual-scroller如果你需要在Angular中处理大量数据并希望优化渲染性能。它适合需要高效渲染的场景。

  • ngx-infinite-scroll:

    如果你在使用Angular并需要简单的无限滚动实现,选择ngx-infinite-scroll。它易于集成,适合快速开发。

  • react-infinite-scroll-component:

    如果你使用React并需要一个易于使用的无限滚动组件,react-infinite-scroll-component是一个不错的选择,特别是对于简单的列表。

  • react-window:

    如果你需要一个轻量级的虚拟化解决方案,react-window是一个很好的选择,适合简单的列表和较小的项目。

react-virtualized的README

React virtualized

React components for efficiently rendering large lists and tabular data. Check out the demo for some 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. Learn more about how the two libraries compare here.

Getting started

Install react-virtualized using npm.

npm install react-virtualized --save

ES6, CommonJS, and UMD builds are available with each distribution. 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';

// But if you only use a few react-virtualized components,
// And you're concerned about increasing your application's bundle size,
// You can directly import only the components you need, like so:
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
import List from 'react-virtualized/dist/commonjs/List';

Note webpack 4 makes this optimization itself, see the documentation.

If the above syntax looks too cumbersome, or you import react-virtualized components from a lot of places, you can also configure a Webpack alias. For example:

// Partial webpack.config.js
{
  alias: {
    'react-virtualized/List': 'react-virtualized/dist/es/List',
  },
  ...rest
}

Then you can just import like so:

import List from 'react-virtualized/List';

// Now you can use <List {...props} />

You can also use a global-friendly UMD build:

<link rel="stylesheet" href="path-to-react-virtualized/styles.css" />
<script src="path-to-react-virtualized/dist/umd/react-virtualized.js"></script>

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 use shallowCompare 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

The shallowCompare method will detect changes to any props, even if they aren't declared as propTypes. 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 and Collection components can be forcefully re-rendered using forceUpdate. 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

API documentation available here.

There are also a couple of how-to guides:

Examples

Examples for each component can be seen in the documentation.

Here are some online demos of each component:

And here are some "recipe" type demos:

Supported Browsers

react-virtualized aims to support all evergreen browsers and recent mobile browsers for iOS and Android. IE 9+ is also supported (although IE 9 will require some user-defined, custom CSS since flexbox layout is not supported).

If you find a browser-specific problem, please report it along with a repro case. The easiest way to do this is probably by forking this Plunker.

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.