Gathering detailed insights and metrics for react-infinite-scroll-component
Gathering detailed insights and metrics for react-infinite-scroll-component
Gathering detailed insights and metrics for react-infinite-scroll-component
Gathering detailed insights and metrics for react-infinite-scroll-component
react-simple-infinite-scroll-patched
A (patched) brutally simple React infinite scroll component
redux-infinite-scroll
React infinite scroll component designed for a Redux data-flow.
react-simple-infinite-scroll
A brutally simple React infinite scroll component
@jacksonrayhamilton/redux-infinite-scroll
React infinite scroll component designed for a Redux data-flow.
An awesome Infinite Scroll component in react.
npm install react-infinite-scroll-component
Remove warning for newer React versions
Published on 20 Apr 2021
v6.0.1
Published on 05 Feb 2021
Change logic for inverse scroll
Published on 05 Feb 2021
Add infinite scroll in up direction
Published on 13 Sept 2020
Pull refresh bug fix
Published on 02 Jun 2020
bug fix - refresh
Published on 02 Jun 2020
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2,887 Stars
210 Commits
322 Forks
20 Watching
30 Branches
28 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
TypeScript (76.19%)
JavaScript (23.81%)
Cumulative downloads
Total Downloads
Last day
-0.9%
149,655
Compared to previous day
Last week
2.3%
757,561
Compared to previous week
Last month
8.7%
3,169,782
Compared to previous month
Last year
12.9%
34,387,118
Compared to previous year
1
1
32
A component to make all your infinite scrolling woes go away with just 4.15 kB! Pull Down to Refresh
feature
added. An infinite-scroll that actually works and super-simple to integrate!
1 npm install --save react-infinite-scroll-component 2 3 or 4 5 yarn add react-infinite-scroll-component 6 7 // in code ES6 8 import InfiniteScroll from 'react-infinite-scroll-component'; 9 // or commonjs 10 var InfiniteScroll = require('react-infinite-scroll-component');
1<InfiniteScroll 2 dataLength={items.length} //This is important field to render the next data 3 next={fetchData} 4 hasMore={true} 5 loader={<h4>Loading...</h4>} 6 endMessage={ 7 <p style={{ textAlign: 'center' }}> 8 <b>Yay! You have seen it all</b> 9 </p> 10 } 11 // below props only if you need pull down functionality 12 refreshFunction={this.refresh} 13 pullDownToRefresh 14 pullDownToRefreshThreshold={50} 15 pullDownToRefreshContent={ 16 <h3 style={{ textAlign: 'center' }}>↓ Pull down to refresh</h3> 17 } 18 releaseToRefreshContent={ 19 <h3 style={{ textAlign: 'center' }}>↑ Release to refresh</h3> 20 } 21> 22 {items} 23</InfiniteScroll>
1<div 2 id="scrollableDiv" 3 style={{ 4 height: 300, 5 overflow: 'auto', 6 display: 'flex', 7 flexDirection: 'column-reverse', 8 }} 9> 10 {/*Put the scroll bar always on the bottom*/} 11 <InfiniteScroll 12 dataLength={this.state.items.length} 13 next={this.fetchMoreData} 14 style={{ display: 'flex', flexDirection: 'column-reverse' }} //To put endMessage and loader to the top. 15 inverse={true} // 16 hasMore={true} 17 loader={<h4>Loading...</h4>} 18 scrollableTarget="scrollableDiv" 19 > 20 {this.state.items.map((_, index) => ( 21 <div style={style} key={index}> 22 div - #{index} 23 </div> 24 ))} 25 </InfiniteScroll> 26</div>
The InfiniteScroll
component can be used in three ways.
height
prop if you want your scrollable content to have a specific height, providing scrollbars for scrolling your content and fetching more data.scrollableTarget
prop to reference the DOM element and use it's scrollbars for fetching more data.height
or scrollableTarget
props, the scroll will happen at document.body
like Facebook's timeline scroll.scrollableTarget
(a parent element which is scrollable)
name | type | description |
---|---|---|
next | function | a function which must be called after reaching the bottom. It must trigger some sort of action which fetches the next data. The data is passed as children to the InfiniteScroll component and the data should contain previous items too. e.g. Initial data = [1, 2, 3] and then next load of data should be [1, 2, 3, 4, 5, 6]. |
hasMore | boolean | it tells the InfiniteScroll component on whether to call next function on reaching the bottom and shows an endMessage to the user |
children | node (list) | the data items which you need to scroll. |
dataLength | number | set the length of the data.This will unlock the subsequent calls to next. |
loader | node | you can send a loader component to show while the component waits for the next load of data. e.g. <h3>Loading...</h3> or any fancy loader element |
scrollThreshold | number | string | A threshold value defining when InfiniteScroll will call next . Default value is 0.8 . It means the next will be called when user comes below 80% of the total height. If you pass threshold in pixels (scrollThreshold="200px" ), next will be called once you scroll at least (100% - scrollThreshold) pixels down. |
onScroll | function | a function that will listen to the scroll event on the scrolling container. Note that the scroll event is throttled, so you may not receive as many events as you would expect. |
endMessage | node | this message is shown to the user when he has seen all the records which means he's at the bottom and hasMore is false |
className | string | add any custom class you want |
style | object | any style which you want to override |
height | number | optional, give only if you want to have a fixed height scrolling content |
scrollableTarget | node or string | optional, reference to a (parent) DOM element that is already providing overflow scrollbars to the InfiniteScroll component. You should provide the id of the DOM node preferably. |
hasChildren | bool | children is by default assumed to be of type array and it's length is used to determine if loader needs to be shown or not, if your children is not an array, specify this prop to tell if your items are 0 or more. |
pullDownToRefresh | bool | to enable Pull Down to Refresh feature |
pullDownToRefreshContent | node | any JSX that you want to show the user, default={<h3>Pull down to refresh</h3>} |
releaseToRefreshContent | node | any JSX that you want to show the user, default={<h3>Release to refresh</h3>} |
pullDownToRefreshThreshold | number | minimum distance the user needs to pull down to trigger the refresh, default=100px , a lower value may be needed to trigger the refresh depending your users browser. |
refreshFunction | function | this function will be called, it should return the fresh data that you want to show the user |
initialScrollY | number | set a scroll y position for the component to render with. |
inverse | bool | set infinite scroll on top |
Thanks goes to these wonderful people (emoji key):
Ankeet Maini 💬 📖 💻 👀 🚧 | Darsh Shah 🚇 |
This project follows the all-contributors specification. Contributions of any kind are welcome!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 5/9 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
114 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