Gathering detailed insights and metrics for react-tiny-virtual-list
Gathering detailed insights and metrics for react-tiny-virtual-list
Gathering detailed insights and metrics for react-tiny-virtual-list
Gathering detailed insights and metrics for react-tiny-virtual-list
@segment/react-tiny-virtual-list
A tiny but mighty list virtualization component, with zero dependencies 💪
react-tiny-virtual-list-oss
A tiny but mighty list virtualization component, with zero dependencies 💪
react-sortable-hoc
Set of higher-order components to turn any list into a sortable, touch-friendly, animated list
rc-virtual-list
React Virtual List Component
A tiny but mighty 3kb list virtualization library, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
npm install react-tiny-virtual-list
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2,465 Stars
93 Commits
164 Forks
18 Watching
16 Branches
6 Contributors
Updated on 26 Nov 2024
Minified
Minified + Gzipped
TypeScript (91.69%)
JavaScript (8.31%)
Cumulative downloads
Total Downloads
Last day
-4.9%
14,159
Compared to previous day
Last week
4.8%
75,339
Compared to previous week
Last month
15.6%
319,559
Compared to previous month
Last year
-18.5%
3,582,500
Compared to previous year
1
1
31
A tiny but mighty list virtualization library, with zero dependencies 💪
Check out the demo for some examples, or take it for a test drive right away in Code Sandbox.
Using npm:
npm install react-tiny-virtual-list --save
ES6, CommonJS, and UMD builds are available with each distribution. For example:
1import VirtualList from 'react-tiny-virtual-list';
You can also use a global-friendly UMD build:
1<script src="react-tiny-virtual-list/umd/react-tiny-virtual-list.js"></script> 2<script> 3var VirtualList = window.VirtualList; 4... 5</script>
1import React from 'react'; 2import {render} from 'react-dom'; 3import VirtualList from 'react-tiny-virtual-list'; 4 5const data = ['A', 'B', 'C', 'D', 'E', 'F', ...]; 6 7render( 8 <VirtualList 9 width='100%' 10 height={600} 11 itemCount={data.length} 12 itemSize={50} // Also supports variable heights (array or function getter) 13 renderItem={({index, style}) => 14 <div key={index} style={style}> // The style property contains the item's absolute position 15 Letter: {data[index]}, Row: #{index} 16 </div> 17 } 18 />, 19 document.getElementById('root') 20);
Property | Type | Required? | Description |
---|---|---|---|
width | Number | String* | ✓ | Width of List. This property will determine the number of rendered items when scrollDirection is 'horizontal' . |
height | Number | String* | ✓ | Height of List. This property will determine the number of rendered items when scrollDirection is 'vertical' . |
itemCount | Number | ✓ | The number of items you want to render |
renderItem | Function | ✓ | Responsible for rendering an item given it's index: ({index: number, style: Object}): React.PropTypes.node . The returned element must handle key and style. |
itemSize | ✓ | Either a fixed height/width (depending on the scrollDirection), an array containing the heights of all the items in your list, or a function that returns the height of an item given its index: (index: number): number | |
scrollDirection | String | Whether the list should scroll vertically or horizontally. One of 'vertical' (default) or 'horizontal' . | |
scrollOffset | Number | Can be used to control the scroll offset; Also useful for setting an initial scroll offset | |
scrollToIndex | Number | Item index to scroll to (by forcefully scrolling if necessary) x | |
scrollToAlignment | String | Used in combination with scrollToIndex , this prop controls the alignment of the scrolled to item. One of: 'start' , 'center' , 'end' or 'auto' . Use 'start' to always align items to the top of the container and 'end' to align them bottom. Use 'center ' to align them in the middle of the container. 'auto' scrolls the least amount possible to ensure that the specified scrollToIndex item is fully visible. | |
stickyIndices | Number[] | An array of indexes (eg. [0, 10, 25, 30] ) to make certain items in the list sticky (position: sticky ) | |
overscanCount | Number | Number of extra buffer items to render above/below the visible items. Tweaking this can help reduce scroll flickering on certain browsers/devices. | |
estimatedItemSize | Number | Used to estimate the total size of the list before all of its items have actually been measured. The estimated total height is progressively adjusted as items are rendered. | |
onItemsRendered | Function | Callback invoked with information about the slice of rows/columns that were just rendered. It has the following signature: ({startIndex: number, stopIndex: number}) . | |
onScroll | Function | Callback invoked whenever the scroll offset changes within the inner scrollable region. It has the following signature: (scrollTop: number, event: React.UIEvent<HTMLDivElement>) . |
* Width may only be a string when scrollDirection
is 'vertical'
. Similarly, Height may only be a string if scrollDirection
is 'horizontal'
This method force recomputes the item sizes after the specified index (these are normally cached).
VirtualList
has no way of knowing when its underlying data has changed, since it only receives a itemSize property. If the itemSize is a number
, this isn't an issue, as it can compare before and after values and automatically call recomputeSizes
internally.
However, if you're passing a function to itemSize
, that type of comparison is error prone. In that event, you'll need to call recomputeSizes
manually to inform the VirtualList
that the size of its items has changed.
react-tiny-virtual-list
uses PureComponent, so it only updates when it's props change. Therefore, if only the order of your data changes (eg ['a','b','c']
=> ['d','e','f']
), react-tiny-virtual-list
has no way to know your data has changed and that it needs to re-render.
You can force it to re-render by calling forceUpdate on it or by passing it an extra prop that will change every time your data changes.
Found an issue? Please report it along with any relevant details to reproduce it. If you can, please provide a live demo replicating the issue you're describing. You can fork this Code Sandbox as a starting point.
Feature requests / pull requests are welcome, though please take a moment to make sure your contributions fits within the scope of the project. Learn how to contribute
This library draws inspiration from react-virtualized, and is meant as a bare-minimum replacement for the List component. If you're looking for a tiny, lightweight and dependency-free list virtualization library that supports variable heights, you're in the right place! If you're looking for something that supports more use-cases, I highly encourage you to check out react-virtualized instead, it's a fantastic library ❤️
react-tiny-virtual-list is available under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/21 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
135 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More