react-window vs react-virtualized vs react-virtual
리액트 가상 스크롤 라이브러리
react-windowreact-virtualizedreact-virtual유사 패키지:

리액트 가상 스크롤 라이브러리

리액트 가상 스크롤 라이브러리는 대량의 데이터를 효율적으로 렌더링하기 위해 설계된 도구입니다. 이 라이브러리들은 화면에 표시되는 데이터의 양을 줄여 성능을 최적화하고, 스크롤 성능을 향상시키며, 사용자 경험을 개선하는 데 도움을 줍니다. 각각의 라이브러리는 고유한 기능과 설계 원칙을 가지고 있어, 특정 사용 사례에 따라 선택할 수 있습니다.

npm 다운로드 트렌드

3 년

GitHub Stars 순위

통계 세부사항

패키지
다운로드
Stars
크기
Issues
발행일
라이선스
react-window8,413,68617,200419 kB18時間前MIT
react-virtualized2,311,88927,0671.31 MB112日前MIT
react-virtual654,6957,178158 kB84-MIT

기능 비교: react-window vs react-virtualized vs react-virtual

성능 최적화

  • react-window:

    react-window는 최소한의 오버헤드로 가상화 기능을 제공하여, 성능을 극대화합니다. 간단한 API와 함께 빠른 렌더링을 지원하며, 작은 데이터 집합에 최적화되어 있습니다.

  • react-virtualized:

    react-virtualized는 다양한 데이터 구조를 지원하며, 복잡한 UI 구성 요소를 효율적으로 렌더링합니다. 고급 최적화 기술을 사용하여 스크롤 성능을 극대화하고, 대량의 데이터를 처리할 수 있습니다.

  • react-virtual:

    react-virtual은 기본적인 가상화 기능을 제공하여, 화면에 보이는 데이터만 렌더링함으로써 성능을 최적화합니다. 간단한 API를 통해 쉽게 구현할 수 있으며, 적은 메모리 사용량으로 빠른 렌더링을 지원합니다.

사용 용이성

  • react-window:

    react-window는 간단하고 직관적인 API를 제공하여, 사용하기 쉽고 빠르게 설정할 수 있습니다. 기본적인 가상화 기능을 필요로 하는 경우에 적합합니다.

  • react-virtualized:

    react-virtualized는 다양한 기능을 제공하지만, 그만큼 설정이 복잡할 수 있습니다. 고급 기능이 필요한 경우에는 유용하지만, 초보자에게는 다소 어려울 수 있습니다.

  • react-virtual:

    react-virtual은 간단한 API를 제공하여 사용하기 쉽고, 빠르게 구현할 수 있습니다. 복잡한 설정 없이 기본적인 가상화 기능을 필요로 하는 프로젝트에 적합합니다.

기능 확장성

  • react-window:

    react-window는 기본적인 가상화 기능에 초점을 맞추고 있어, 고급 기능이 필요할 경우 다른 라이브러리와 함께 사용할 수 있습니다. 그러나 기능 확장성은 react-virtualized보다 제한적입니다.

  • react-virtualized:

    react-virtualized는 다양한 기능과 옵션을 제공하여, 필요에 따라 쉽게 확장할 수 있습니다. 복잡한 데이터 구조와 다양한 UI 요구 사항을 처리할 수 있습니다.

  • react-virtual:

    react-virtual은 기본적인 가상화 기능을 제공하며, 추가적인 기능이 필요할 경우 다른 라이브러리와 함께 사용할 수 있습니다. 그러나 확장성이 제한적일 수 있습니다.

커스터마이징

  • react-window:

    react-window는 기본적인 커스터마이징 기능을 제공하지만, react-virtualized에 비해 옵션이 적습니다. 간단한 커스터마이징이 필요한 경우에 적합합니다.

  • react-virtualized:

    react-virtualized는 다양한 커스터마이징 옵션을 제공하여, 복잡한 UI와 데이터 구조를 처리할 수 있습니다. 사용자 정의 렌더러를 통해 유연하게 구현할 수 있습니다.

  • react-virtual:

    react-virtual은 기본적인 커스터마이징 옵션을 제공하지만, 복잡한 UI 요구 사항을 처리하기에는 제한적일 수 있습니다.

지원 및 커뮤니티

  • 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는 더 많은 기능과 유연성을 제공하며, 복잡한 데이터 구조와 다양한 UI 구성 요소를 처리해야 할 때 적합합니다. 다양한 기능이 필요하고, 성능 최적화가 중요한 대규모 애플리케이션에 적합합니다.

  • react-virtual:

    react-virtual은 간단하고 가벼운 가상화 솔루션을 제공하며, 기본적인 가상 스크롤 기능이 필요할 때 적합합니다. 복잡한 기능이 필요하지 않거나, 작은 프로젝트에서 빠르게 구현하고자 할 때 선택하세요.

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.

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 list's current height (string)
  • function that returns the row height (in pixels) given an index and rowProps
  • dynamic row height cache returned by the useDynamicRowHeight hook

ℹ️ Percentage heights can't be resolved during server rendering unless a defaultHeight (or a pixel height via the style prop) is specified.

⚠️ 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 rows). This property can be used to render things like overlays or tooltips.

defaultHeight

Default height of list (in pixels) for initial render, before its actual height has been measured.

ℹ️ Lists can't be measured during server rendering, so this value determines how many rows are server rendered. It's recommended to set this to the expected height of the list (or to specify a pixel height via the style prop).

defaultScrollOffset

Initial scroll offset (in pixels) of the list. This value is only applied once, when the list first mounts with at least one row.

ℹ️ Server-rendered HTML can't be pre-scrolled, so server rendering always starts at the first row; the default scroll offset is applied once the list hydrates.

⚠️ If the list can't be scrolled that far when the offset is applied (e.g. it is hidden with display: none, or uses percentage row heights before its height has been measured), the offset is clamped or ignored and not retried. Specify a defaultHeight (or a pixel height via the style prop) when using percentage row heights.

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

rowKey

Lists use the row index as a key by default. This prop can provide a custom key value.

ℹ️ Custom keys can ensure better UX for sortable or filterable lists, particularly if your row components are stateful. Refer to the React documentation for more info.

⚠️ This prop cannot be auto-memoized because it is called during render. It is important to always useCallback for this prop; do not use an inline function.

scrollElement

Element that scrolls the list, for lists that scroll along with other content (e.g. the page):

  • "window" to scroll with the page
  • an ancestor element that scrolls (e.g. stored with a useState ref callback); null until it has mounted

The list renders at its full height and only renders the rows visible within the scroll element's viewport. Its position within the scroll element is measured whenever it renders, scrolls, or resizes, and whenever content before it is resized, inserted, or removed (e.g. an image loading above the list).

  • scrollToRow scrolls the scroll element
  • defaultHeight is used as the viewport height until the scroll element has been measured (e.g. during server rendering)
  • percentage row heights are relative to the scroll element's viewport height
  • defaultScrollOffset is ignored

ℹ️ While the scroll element is null, the list renders the first rows (as it does during server rendering).

⚠️ The list itself doesn't scroll, so its onScroll handler isn't called; listen to the scroll element's "scroll" events instead (or use the useIsScrolling hook).

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 columnIndex, rowIndex, and style props 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

ℹ️ Percentage widths can't be resolved during server rendering unless a defaultWidth (or a pixel width via the style prop) is specified.

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

ℹ️ Percentage heights can't be resolved during server rendering unless a defaultHeight (or a pixel height via the style prop) is specified.

Optional props

NameDescription
className

CSS class name.

dir

Indicates the directionality of grid cells.

ℹ️ The directionality of an ancestor element can't be detected during server rendering; specify this prop explicitly for server-rendered right-to-left grids.

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

columnKey

Grids use the column index as a key by default. This prop can be used along with the rowKey prop to provide a custom key value.

ℹ️ Custom keys can ensure better UX for sortable or filterable grids, particularly if your cell components are stateful. Refer to the React documentation for more info.

⚠️ This prop cannot be auto-memoized because it is called during render. It is important to always useCallback for this prop; do not use an inline function.

defaultHeight

Default height of grid (in pixels) for initial render, before its actual height has been measured.

ℹ️ Grids can't be measured during server rendering, so this value determines how many rows are server rendered. It's recommended to set this to the expected height of the grid (or to specify a pixel height via the style prop).

defaultScrollLeft

Initial horizontal scroll offset (in pixels) of the grid. This value is only applied once, when the grid first mounts with at least one column.

ℹ️ Server-rendered HTML can't be pre-scrolled, so server rendering always starts at the first column; the default scroll offset is applied once the grid hydrates.

⚠️ If the grid can't be scrolled that far when the offset is applied (e.g. it is hidden with display: none, or uses percentage column widths before its width has been measured), the offset is clamped or ignored and not retried. Specify a defaultWidth (or a pixel width via the style prop) when using percentage column widths.

defaultScrollTop

Initial vertical scroll offset (in pixels) of the grid. This value is only applied once, when the grid first mounts with at least one row.

ℹ️ Server-rendered HTML can't be pre-scrolled, so server rendering always starts at the first row; the default scroll offset is applied once the grid hydrates.

⚠️ If the grid can't be scrolled that far when the offset is applied (e.g. it is hidden with display: none, or uses percentage row heights before its height has been measured), the offset is clamped or ignored and not retried. Specify a defaultHeight (or a pixel height via the style prop) when using percentage row heights.

defaultWidth

Default width of grid (in pixels) for initial render, before its actual width has been measured.

ℹ️ Grids can't be measured during server rendering, so this value determines how many columns are server rendered. It's recommended to set this to the expected width of the grid (or to specify a pixel width via the style prop).

gridRef

Imperative Grid API.

ℹ️ The useGridRef and useGridCallbackRef hooks are exported for convenience 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.

rowKey

Grids use the row index as a key by default. This prop can be used along with the columnKey prop to provide a custom key value.

ℹ️ Custom keys can ensure better UX for sortable or filterable grids, particularly if your cell components are stateful. Refer to the React documentation for more info.

⚠️ This prop cannot be auto-memoized because it is called during render. It is important to always useCallback for this prop; do not use an inline function.

scrollElement

Element that scrolls the grid, for grids that scroll along with other content (e.g. the page):

  • "window" to scroll with the page
  • an ancestor element that scrolls (e.g. stored with a useState ref callback); null until it has mounted

The grid renders at its full height and only renders the rows (and columns) visible within the scroll element's viewport. Its position within the scroll element is measured whenever it renders, scrolls, or resizes, and whenever content before it is resized, inserted, or removed (e.g. an image loading above the grid).

  • columns scroll with the scroll element too if the grid is as wide as its content (e.g. style={{ width: "max-content" }}); otherwise the grid fills the width of its parent and its columns scroll within it
  • scrollToCell, scrollToColumn and scrollToRow scroll whichever element scrolls each axis
  • defaultHeight and defaultWidth are used as the viewport size until the scroll element has been measured (e.g. during server rendering)
  • percentage row heights and column widths are relative to the scroll element's viewport
  • defaultScrollLeft and defaultScrollTop are ignored

ℹ️ While the scroll element is null, the grid renders the first rows (as it does during server rendering).

⚠️ The grid's onScroll handler is only called when the grid scrolls its own columns; listen to the scroll element's "scroll" events instead (or use the useIsScrolling hook).

tagName

Can be used to override the root HTML element rendered by the Grid component. The default value is "div", meaning that Grid renders an HTMLDivElement as its root.

⚠️ In most use cases the default ARIA roles are sufficient and this prop is not needed.