1.0.1 • Published 6 years ago

super-react-infinite-scroll v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

super-react-infinite-scroll

Often wondered how facebook or instagram lazily loads data on page scroll and show loading animation?

Well this library provides you with the react component to show loaders while you do API calls or any other async operations.

Installation

Use npm to install super-react-infinite-scroll

npm install super-react-infinite-scroll

Usage

First import super-react-infinite-scroll in to your project

import SuperReactInfiniteScroll from 'super-react-infinite-scroll';
const dataList = [
 <p> item1 </p>,
 <p> item2 </p>
];

const onScrollComplete = () =>{
  console.log('DO API call and get more data');
};

 <SuperReactInfiniteScroll
        loaderElem={<p> Loading..</p>}        
        onScrollComplete={onScrollComplete}
        dataList={dataList}
        totalDataLength={100}
  />

Refer dev/index.js to know the usage better.

Props Usage

PropsDescriptionTypeDefaults
loaderElemReact element to render on lazy fetchReact.Element
onScrollCompletecallback function which is callled when scroll comes to endFunction
dataListList of react elements to renderArrayOf(React.Element)
totalDataLengthLength of Total/final records that will be loadedNumber
scrollThresholdPercentThreshold to call onScrollComplete before scrolling till end of the pageNumber95

Run app locally

To run the dev app locally run the following

npm run start:dev

This project is integrated with mocha and chai for unit testing. To test the code run

npm test