0.1.5 • Published 2 years ago

endless-scrollable v0.1.5

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

endless-scrollable

Installation

yarn add endless-scrollable

or

npm install endless-scrollable --save

Usage

Clones ComponentToCopy infinitely:

const List = () => {
    return (
        <EndlessScrollable item={ComponentToCopy} />
    )
}

More practical example:

const List = () => {
    const [page, setPage] = useState(1);

  /**
   * ComponentToCopy will get {page}
   * which can be used to fetch some more data out of ComponentToCopy
   */
    return (
        <EndlessScrollable item={ComponentToCopy} itemProps={{ page, setPage }} />
    )
}

Props

NameTypeRequiredDescription
itemReact.ComponentType<IItem>trueComponent's props must implement IITem interface
itemPropsIItemPropsfalseinterface IItemProps { [prop: string]: any; }
intersectionOptionsobjectfalsehttps://github.com/thebuilder/react-intersection-observer#options
classNamestringfalsewrapper's classname

More examples in storybook

Clone repo

cd endless-scrollable/
yarn install
yarn storybook