react-virtualized vs react-infinite vs react-infinite-scroll-component vs react-window
React Infinite Scrolling Libraries
react-virtualizedreact-infinitereact-infinite-scroll-componentreact-window类似的npm包:

React Infinite Scrolling Libraries

Infinite scrolling libraries for React are designed to enhance user experience by loading content dynamically as the user scrolls down the page. This technique helps in improving performance and reducing load times by fetching data in smaller chunks rather than loading everything at once. These libraries provide various features such as virtualization, scrolling detection, and customizable loading indicators, making it easier for developers to implement infinite scrolling in their applications.

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
react-virtualized1,723,75827,0671.31 MB18 天前MIT
react-infinite02,682243 kB101-BSD-3-Clause
react-infinite-scroll-component03,091217 kB1385 个月前MIT
react-window017,200417 kB03 分钟前MIT

功能对比: react-virtualized vs react-infinite vs react-infinite-scroll-component vs react-window

Performance Optimization

  • react-virtualized:

    react-virtualized excels in performance optimization, rendering only the visible items in a list or table, which is crucial for applications dealing with large datasets. It minimizes DOM updates and improves rendering speed significantly.

  • react-infinite:

    react-infinite provides basic infinite scrolling capabilities but lacks advanced optimizations for rendering large datasets, making it less suitable for performance-critical applications.

  • react-infinite-scroll-component:

    This package offers a good balance of performance and ease of use, allowing for smooth scrolling experiences without heavy overhead, suitable for most applications.

  • react-window:

    react-window is designed for high performance with a minimal footprint, focusing on rendering only the visible items efficiently, making it an excellent choice for large lists.

Ease of Use

  • react-virtualized:

    While powerful, react-virtualized has a steeper learning curve due to its extensive features and configuration options, which may require more time to master.

  • react-infinite:

    react-infinite is straightforward to implement, requiring minimal configuration, making it suitable for developers looking for a quick solution without complex setup.

  • react-infinite-scroll-component:

    This library is user-friendly and flexible, providing a simple API that allows for easy integration into existing projects, making it ideal for developers of all skill levels.

  • react-window:

    react-window is designed to be simple and intuitive, making it easy to use for developers who need a quick solution for rendering large lists without the complexity of react-virtualized.

Feature Set

  • react-virtualized:

    react-virtualized comes with a comprehensive set of features for virtualization, including windowing, dynamic row heights, and more, making it suitable for complex data presentations.

  • react-infinite:

    react-infinite offers basic infinite scrolling features but lacks advanced functionalities such as virtualization or customizable loading states, which may limit its use in complex applications.

  • react-infinite-scroll-component:

    This package provides a rich feature set, including support for both scroll and touch events, customizable loading indicators, and easy integration with existing components.

  • react-window:

    react-window focuses on providing essential features for virtualization in a lightweight manner, making it easy to implement while still offering good performance.

Community and Support

  • react-virtualized:

    With a large user base and extensive documentation, react-virtualized offers robust community support and a wealth of resources for troubleshooting and implementation.

  • react-infinite:

    react-infinite has a smaller community and less frequent updates, which may affect long-term support and the availability of resources.

  • react-infinite-scroll-component:

    This library has a growing community and active maintenance, providing good support and resources for developers.

  • react-window:

    react-window, being a lightweight alternative to react-virtualized, has a supportive community and is well-documented, making it easy for developers to find help and examples.

Customization

  • react-virtualized:

    react-virtualized provides extensive customization capabilities, allowing developers to define custom renderers for rows and cells, making it highly adaptable for various use cases.

  • react-infinite:

    react-infinite offers limited customization options, which may restrict developers looking for specific behaviors or styles in their infinite scrolling implementation.

  • react-infinite-scroll-component:

    This library allows for a high degree of customization, enabling developers to tailor the loading indicators and scrolling behavior to fit their application's needs.

  • react-window:

    react-window supports basic customization options, focusing on simplicity while still allowing developers to adjust styles and behaviors as needed.

如何选择: react-virtualized vs react-infinite vs react-infinite-scroll-component vs react-window

  • react-virtualized:

    Select react-virtualized when you need advanced performance optimizations for rendering large lists or tables. It provides a comprehensive set of components for virtualization, allowing you to render only the visible items in the viewport, which can significantly improve performance.

  • react-infinite:

    Choose react-infinite if you need a straightforward solution for infinite scrolling with basic features and don't require advanced virtualization or performance optimizations.

  • react-infinite-scroll-component:

    Opt for react-infinite-scroll-component if you want a simple and flexible implementation of infinite scrolling that supports both scroll and touch events, making it suitable for mobile and desktop applications.

  • react-window:

    Choose react-window for a lightweight alternative to react-virtualized, focusing on simplicity and performance. It is ideal for rendering large lists with minimal overhead and is easier to integrate into existing projects.

react-virtualized的README

React virtualized

React components for efficiently rendering large lists and tabular data. Check out the documentation for live 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.

Getting started

Install react-virtualized using npm.

npm install react-virtualized --save

ES module and CommonJS builds are included, along with TypeScript type definitions. 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';

The package is marked as side-effect free (other than its CSS), so bundlers will tree-shake any components you don't use.

TypeScript types are exported for each component's props (e.g. ListProps, GridProps, TableProps) along with the parameters passed to renderers (e.g. RowRendererParams, CellRendererParams, TableCellProps).

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 are wrapped in memo 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

This shallow comparison will detect changes to any props, even ones a component doesn't use. 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 components can be forcefully re-rendered by calling forceUpdate on their ref. 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

Documentation and live examples for every component are available at react-virtualized-docs.vercel.app.

Components:

CellMeasurer measures cells whose sizes aren't known ahead of time.

Grid, List, Masonry and Table can also be scrolled by the window (or another scrollable element) with the scrollElement prop.

Higher-order components:

[!NOTE] AutoSizer is no longer part of react-virtualized (as of version 10); it is available as the separate react-virtualized-auto-sizer package. See sizing components for how to use it with react-virtualized.

There are also a couple of how-to guides:

Examples

Here are some "recipe" type demos:

Supported Browsers

react-virtualized aims to support all evergreen browsers and recent mobile browsers for iOS and Android.

If you find a browser-specific problem, please report it along with a repro case (e.g. a CodeSandbox).

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.