import React, { PropsWithChildren } from 'react'; import { LoadingIndicator as DefaultLoadingIndicator } from 'react-file-utils'; import { InfiniteScroll } from './InfiniteScroll'; import { ElementOrComponentOrLiteralType, smartRender } from '../utils'; export type InfiniteScrollPaginatorProps = PropsWithChildren<{ /** indicates if there is a next page to load */ hasNextPage?: boolean; /** the loading indicator to use */ Loader?: ElementOrComponentOrLiteralType; /** callback to load the next page */ loadNextPage?: () => void; /** indicates if there there's currently any refreshing taking place */ refreshing?: boolean; /** display the items in opposite order */ reverse?: boolean; /** offset from when to start the loadNextPage call */ threshold?: number; /** use Window as parent scrolling container */ useWindow?: boolean; }>; export const InfiniteScrollPaginator = (props: InfiniteScrollPaginatorProps) => { const { children, hasNextPage, Loader = DefaultLoadingIndicator, loadNextPage, refreshing, reverse, threshold, useWindow, } = props; return ( {smartRender(Loader)}} loadMore={loadNextPage} threshold={threshold} useWindow={useWindow} > {children} ); };