1.0.0 • Published 1 year ago

react-infinite-scroll-observer v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

React Infinite Scroll Observer

Inspired by component react-infinite-scroll-component .

Install

yarn add react-infinite-scroll-observer

or

npm i react-infinite-scroll-observer

Usage

How to import:

import { InfiniteScrollObserver } from 'react-infinite-scroll-observer';

Main properties:

<InfiniteScrollObserver
  onLoadNext={onFetchData}
  dataLength={items.length}
  hasMore={true}
  className='infinite-scroll-controller'
  scrollableTargetId="observable-infinite-scroll"
  loaderComponent={
    <Loader id="observable-infinite-scroll"/>
  }
>
  {items}
</InfiniteScrollObserver>

Configuration properties

NameTypeRequiredDescription
childrenReactNodetrueThe data items which you need to scroll
loaderComponentReactNodetrueA loader component to show while the component waits for the next
scrollableTargetIdStringtrueHTML attribute ID of the informed loading component. Quando aparecer na tela, chamará a função onLoadNext
dataLengthNumbertrueLength of the informed data. If greater than 0, will enable observation of scrollableTargetId
hasMoreBooleantrueIt tells the InfiniteScrollObserver component on whether to call onLoadNext function on reaching the end of the scroll. If value false, not show the loaderComponent
isReverseBooleanfalseSet infinite scroll in direction top
isHideLoaderBooleanfalseIf you don't want to show the loaderComponent at another time
classNameBooleanfalseAdd a CSS custom class
onLoadNextVoid FunctiontrueA function which must be called after finding the DOM element (loaderComponent) with the ID attribute of scrollableTargetId. It must trigger some sort of action which fetches the next data.

Contributing

Contributors are welcome! :metal:

Please check out the CONTRIBUTING.md.

You can also:

  • :star2: give a star in this repository
  • :heavy_heart_exclamation: share this project and recommending it to your friends

Contributors

License

Licensed under the MIT License