Infinite Scroll
React native infinite scroll component for Android & iOS.
Tested with Android 4.1+ and iOS 10.
Install
npm install --save react-native-infinite-scroll
Usage
<InfiniteScroll // make sure to use a function signature, not this.loadMorePages()! onLoadMoreAsync=thisloadMorePages horizontal=false // true - if you want in horizontal style=stylesscrollView ...prop> ...children</InfiniteScroll>
Example
;;; { var ds = r1 !== r2; var rows = "China""Korea""Singapore""Malaysia" return data: rows dataSource: ds } { //here .. collect the data from server somehow let new_data = 'Japan''Myanmar''India''Thailand'; let rows = thisstatedata; rowspush; this; } { return <InfiniteScroll horizontal=false //true - if you want in horizontal onLoadMoreAsync=thisloadMorePage distanceFromEnd=10 // distance in density-independent pixels from the right end style=stylesscrollView> <ListView enableEmptySections=true dataSource=thisstatedataSource renderRow=<Text>data</Text> /> </InfiniteScroll> ; }; ;
API
You can pass any ScrollView property here.
Plus you can provide the following:
onLoadMoreAsync
[Function] no default reference callback to be executed whenever we reach the end of our scrolling area (the end is not represented by the right border but it's the right border - offset defined bydistanceFromEnd
)distanceFromEnd
[Number] 10 the distance we should callonLoadMoreAsync
before to reach the right border, useful to get the content before the user hits the end (causing it to stop scrolling while content is loading). You should calculate this with regard to the needed time to render new content (network latency/computing time) and estimate your average item size. The right amount of dp is up to you.
Credits
Originally based on infinite-scroll-x