Gathering detailed insights and metrics for react-window-infinite-loader
Gathering detailed insights and metrics for react-window-infinite-loader
Gathering detailed insights and metrics for react-window-infinite-loader
Gathering detailed insights and metrics for react-window-infinite-loader
@types/react-window-infinite-loader
TypeScript definitions for react-window-infinite-loader
react-window-infinite-scroll
'react-window' infinite scroller (loader) that fetches data on data change.
inferno-window-infinite-loader
This is a port of the origin library written in React, InfiniteLoader component inspired by react-virtualized but for use with react-window
react-infinitum
React Infinitum is a window infinite scroll loader
InfiniteLoader component inspired by react-virtualized but for use with react-window
npm install react-window-infinite-loader
Typescript
Module System
Min. Node Version
Node Version
NPM Version
92.9
Supply Chain
93.4
Quality
79
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
56,919,234
Last Day
9,541
Last Week
370,016
Last Month
1,523,417
Last Year
16,173,401
MIT License
939 Stars
43 Commits
46 Forks
9 Watchers
1 Branches
10 Contributors
Updated on May 08, 2025
Minified
Minified + Gzipped
Latest Version
1.0.10
Package Id
react-window-infinite-loader@1.0.10
Unpacked Size
28.15 kB
Size
6.56 kB
File Count
5
NPM Version
9.6.6
Node Version
20.2.0
Published on
Jan 25, 2025
Cumulative downloads
Total Downloads
Last Day
6.3%
9,541
Compared to previous day
Last Week
11.9%
370,016
Compared to previous week
Last Month
-11%
1,523,417
Compared to previous month
Last Year
13.3%
16,173,401
Compared to previous year
36
InfiniteLoader component inspired by react-virtualized but for use with react-window
1# Yarn 2yarn add react-window-infinite-loader 3 4# NPM 5npm install --save react-window-infinite-loader
Name | Type | Description |
---|---|---|
children | ({ onItemsRendered: Function, ref: React$Ref }) => React$Node | Render prop. See below for example usage. |
isItemLoaded | (index: number) => boolean | Function responsible for tracking the loaded state of each item. |
itemCount | number | Number of rows in list; can be arbitrary high number if actual number is unknown. |
loadMoreItems | (startIndex: number, stopIndex: number) => Promise<void> | Callback to be invoked when more rows must be loaded. It should return a Promise that is resolved once all data has finished loading. |
minimumBatchSize | ?number | Minimum number of rows to be loaded at a time; defaults to 10. This property can be used to batch requests to reduce HTTP requests. |
threshold | ?number | Threshold at which to pre-fetch data; defaults to 15. A threshold of 15 means that data will start loading when a user scrolls within 15 rows. |
The snippet below shows a basic example of how the InfiniteLoader
can be used to wrap either a FixedSizeList
or VariableSizeList
from react-window
.
1// This value is arbitrary. 2// If you know the size of your remote data, you can provide a real value. 3// You can also increase this value gradually (as shown in the example below). 4const itemCount = 1000; 5 6<InfiniteLoader 7 isItemLoaded={isItemLoaded} 8 itemCount={itemCount} 9 loadMoreItems={loadMoreItems} 10> 11 {({ onItemsRendered, ref }) => ( 12 <FixedSizeList 13 itemCount={itemCount} 14 onItemsRendered={onItemsRendered} 15 ref={ref} 16 {...otherListProps} 17 /> 18 )} 19</InfiniteLoader>
The InfiniteLoader
component was created to help break large data sets down into chunks that could be just-in-time loaded as they were scrolled into view.
It can also be used to create infinite loading lists (e.g. Facebook or Twitter).
Here's a basic example of how you might implement that:
1function ExampleWrapper({ 2 // Are there more items to load? 3 // (This information comes from the most recent API request.) 4 hasNextPage, 5 6 // Are we currently loading a page of items? 7 // (This may be an in-flight flag in your Redux store for example.) 8 isNextPageLoading, 9 10 // Array of items loaded so far. 11 items, 12 13 // Callback function responsible for loading the next page of items. 14 loadNextPage 15}) { 16 // If there are more items to be loaded then add an extra row to hold a loading indicator. 17 const itemCount = hasNextPage ? items.length + 1 : items.length; 18 19 // Only load 1 page of items at a time. 20 // Pass an empty callback to InfiniteLoader in case it asks us to load more than once. 21 const loadMoreItems = isNextPageLoading ? () => {} : loadNextPage; 22 23 // Every row is loaded except for our loading indicator row. 24 const isItemLoaded = index => !hasNextPage || index < items.length; 25 26 // Render an item or a loading indicator. 27 const Item = ({ index, style }) => { 28 let content; 29 if (!isItemLoaded(index)) { 30 content = "Loading..."; 31 } else { 32 content = items[index].name; 33 } 34 35 return <div style={style}>{content}</div>; 36 }; 37 38 return ( 39 <InfiniteLoader 40 isItemLoaded={isItemLoaded} 41 itemCount={itemCount} 42 loadMoreItems={loadMoreItems} 43 > 44 {({ onItemsRendered, ref }) => ( 45 <FixedSizeList 46 itemCount={itemCount} 47 onItemsRendered={onItemsRendered} 48 ref={ref} 49 {...props} 50 > 51 {Item} 52 </FixedSizeList> 53 )} 54 </InfiniteLoader> 55 ); 56}
Some use cases require cached items to be reset. For example, after a list has been sorted, previously cached items may be invalid. You can let InfiniteLoader
know that it needs to reload cached items by calling the resetloadMoreItemsCache
method.
1function ExampleWrapper({ 2 // ... 3 sortOrder, 4}) { 5 // We create a reference for the InfiniteLoader 6 const infiniteLoaderRef = useRef(null); 7 const hasMountedRef = useRef(false); 8 9 // Each time the sort prop changed we called the method resetloadMoreItemsCache to clear the cache 10 useEffect(() => { 11 // We only need to reset cached items when "sortOrder" changes. 12 // This effect will run on mount too; there's no need to reset in that case. 13 if (hasMountedRef.current) { 14 if (infiniteLoaderRef.current) { 15 infiniteLoaderRef.current.resetloadMoreItemsCache(); 16 } 17 } 18 hasMountedRef.current = true; 19 }, [sortOrder]); 20 21 // ... 22 23 // We passed down the ref to the InfiniteLoader component 24 return ( 25 <InfiniteLoader 26 ref={infiniteLoaderRef} 27 isItemLoaded={isItemLoaded} 28 itemCount={itemCount} 29 loadMoreItems={loadMoreItems} 30 > 31 {({ onItemsRendered, ref }) => ( 32 // ... 33 )} 34 </InfiniteLoader> 35 ); 36}
MIT © bvaughn
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 6/17 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
153 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
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