An awesome Infinite Scroll component in react.
Installations
npm install react-infinite-scroll-component
Releases
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
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
14.16.1
NPM Version
6.14.12
Statistics
2,887 Stars
210 Commits
322 Forks
20 Watching
30 Branches
28 Contributors
Updated on 27 Nov 2024
Bundle Size
7.58 kB
Minified
2.53 kB
Minified + Gzipped
Languages
TypeScript (76.19%)
JavaScript (23.81%)
Total Downloads
Cumulative downloads
Total Downloads
103,999,947
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
1
Dev Dependencies
32
react-infinite-scroll-component
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!
Install
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');
Using
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>
Using scroll on top
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.
- Specify a value for the
height
prop if you want your scrollable content to have a specific height, providing scrollbars for scrolling your content and fetching more data. - If your scrollable content is being rendered within a parent element that is already providing overflow scrollbars, you can set the
scrollableTarget
prop to reference the DOM element and use it's scrollbars for fetching more data. - Without setting either the
height
orscrollableTarget
props, the scroll will happen atdocument.body
like Facebook's timeline scroll.
docs version wise
live examples
- infinite scroll (never ending) example using react (body/window scroll)
- infinte scroll till 500 elements (body/window scroll)
- infinite scroll in an element (div of height 400px)
- infinite scroll with
scrollableTarget
(a parent element which is scrollable)
props
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 |
Contributors ✨
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!
LICENSE
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
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
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/push.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/ankeetmaini/react-infinite-scroll-component/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/push.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/ankeetmaini/react-infinite-scroll-component/push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/push.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/ankeetmaini/react-infinite-scroll-component/push.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 26 are checked with a SAST tool
Reason
114 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-6h5x-7c5m-7cr7
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-vfrc-7r7c-w9mx
- Warn: Project is vulnerable to: GHSA-7wwv-vh3v-89cq
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-ccrp-c664-8p4j
- Warn: Project is vulnerable to: GHSA-4wx3-54gh-9fr9
- Warn: Project is vulnerable to: GHSA-ch52-vgq2-943f
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-r6rj-9ch6-g264
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-wvhm-4hhf-97x9
- Warn: Project is vulnerable to: GHSA-h4hr-7fg3-h35w
- Warn: Project is vulnerable to: GHSA-gj77-59wh-66hg
- Warn: Project is vulnerable to: GHSA-hqhp-5p83-hx96
- Warn: Project is vulnerable to: GHSA-3949-f494-cm99
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-5q6m-3h65-w53x
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-9m6j-fcg5-2442
- Warn: Project is vulnerable to: GHSA-hh27-ffr2-f2jc
- Warn: Project is vulnerable to: GHSA-rqff-837h-mm52
- Warn: Project is vulnerable to: GHSA-8v38-pw62-9cw2
- Warn: Project is vulnerable to: GHSA-hgjh-723h-mx2j
- Warn: Project is vulnerable to: GHSA-jf5r-8hm2-f872
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-g78m-2chm-r7qv
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
3
/10
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 MoreOther packages similar to 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.