@readr-media/react-infinite-scroll-list
Version:
The component progressively fetches data when page being scrolled to bottom and renders them.
27 lines • 1.31 kB
TypeScript
import { type ReactNode } from 'react';
type Props<T> = {
/** The initial data list to render */
initialList?: T[] | null;
/** Maximum of items to be rendered */
amountOfElements?: number;
/** Maxmium of fetches to be fired */
pageAmount?: number;
/** The amount of items per scroll page */
pageSize: number;
/** The function to fetch more data, which will be executed when page is scrolled to bottom */
fetchListInPage: (page: number) => Promise<T[]>;
/** The function to render data list */
children: (renderList: T[], customTriggerRef?: React.RefObject<HTMLElement>) => ReactNode;
/** The loader element to display during data loading */
loader?: ReactNode;
/** Whether the custom trigger ref will provided throught children callback to set up trigger point */
hasCustomTrigger?: boolean;
/** Whether data fetch is executed atomatically */
isAutoFetch?: boolean;
};
/**
* This component will progressively fetch data and render theme
*/
export default function InfiniteScrollList<T>({ initialList, amountOfElements, pageAmount, pageSize, isAutoFetch, fetchListInPage, children, loader, hasCustomTrigger, }: Props<T>): import("react").JSX.Element;
export {};
//# sourceMappingURL=infinite-scroll-list.d.ts.map