react-window-infinite-loader
Version:
Infinite loader utils inspired by `react-virtualized` but for use with `react-window`.
43 lines (37 loc) • 1.41 kB
TypeScript
declare type Indices = {
startIndex: number;
stopIndex: number;
};
export declare function InfiniteLoader({ children, ...props }: Props & {
children: (paras: {
onRowsRendered: OnRowsRendered;
}) => void;
}): void;
declare type OnRowsRendered = (indices: Indices) => void;
declare type Props = {
/**
* Function responsible for tracking the loaded state of each item.
*/
isRowLoaded: (index: number) => boolean;
/**
* Callback to be invoked when more rows must be loaded.
* It should return a Promise that is resolved once all data has finished loading.
*/
loadMoreRows: (startIndex: number, stopIndex: number) => Promise<void>;
/**
* Minimum number of rows to be loaded at a time; defaults to 10.
* This property can be used to batch requests to reduce HTTP requests.
*/
minimumBatchSize?: number;
/**
* Threshold at which to pre-fetch data; defaults to 15.
* A threshold of 15 means that data will start loading when a user scrolls within 15 rows.
*/
threshold?: number;
/**
* Number of rows in list; can be arbitrary high number if actual number is unknown.
*/
rowCount: number;
};
export declare function useInfiniteLoader({ isRowLoaded, loadMoreRows, minimumBatchSize, rowCount, threshold, }: Props): OnRowsRendered;
export { }