DefinitelyTyped/types/react-virtualized/InfiniteLoader.d.ts
Kalle Ott 8484faf774 update for react-virtualized 9.4
replaced single declaration file with multiple files to represent the module structure of react-virtualized. 
This makes the future maintanance easier, because changes in the lib can be easier mirrored in the corresponding declaration file.
This typings update should be the last with large breaking changes
2017-03-27 21:23:45 +02:00

81 lines
3.0 KiB
TypeScript

import { PureComponent, Validator, Requireable } from 'react'
import { Index, IndexRange } from './genericTypes';
export type InfiniteLoaderChildProps = {
onRowsRendered: (params: { startIndex: number, stopIndex: number }) => void,
registerChild: (registeredChild: any) => void
}
export type InfiniteLoaderProps = {
children?: (props: InfiniteLoaderChildProps) => React.ReactNode;
isRowLoaded: (params: Index) => boolean;
loadMoreRows: (params: IndexRange) => Promise<any>;
minimumBatchSize?: number;
rowCount?: number;
threshold?: number;
};
/**
* Higher-order component that manages lazy-loading for "infinite" data.
* This component decorates a virtual component and just-in-time prefetches rows as a user scrolls.
* It is intended as a convenience component; fork it if you'd like finer-grained control over data-loading.
*/
export class InfiniteLoader extends PureComponent<InfiniteLoaderProps, {}> {
static propTypes: {
/**
* Function responsible for rendering a virtualized component.
* This function should implement the following signature:
* ({ onRowsRendered, registerChild }) => PropTypes.element
*
* The specified :onRowsRendered function should be passed through to the child's :onRowsRendered property.
* The :registerChild callback should be set as the virtualized component's :ref.
*/
children: Validator<(props: InfiniteLoaderChildProps) => React.ReactNode>,
/**
* Function responsible for tracking the loaded state of each row.
* It should implement the following signature: ({ index: number }): boolean
*/
isRowLoaded: Validator<(params: Index) => boolean>,
/**
* Callback to be invoked when more rows must be loaded.
* It should implement the following signature: ({ startIndex, stopIndex }): Promise
* The returned Promise should be resolved once row data has finished loading.
* It will be used to determine when to refresh the list with the newly-loaded data.
* This callback may be called multiple times in reaction to a single scroll event.
*/
loadMoreRows: Validator<(params: IndexRange) => Promise<any>>,
/**
* Minimum number of rows to be loaded at a time.
* This property can be used to batch requests to reduce HTTP requests.
*/
minimumBatchSize: Validator<number>,
/**
* Number of rows in list; can be arbitrary high number if actual number is unknown.
*/
rowCount: Validator<number>,
/**
* Threshold at which to pre-fetch data.
* A threshold X means that data will start loading when a user scrolls within X rows.
* This value defaults to 15.
*/
threshold: Validator<number>
};
static defaultProps: {
minimumBatchSize: 10,
rowCount: 0,
threshold: 15
};
constructor(props: InfiniteLoaderProps, context: any);
resetLoadMoreRowsCache(): void;
render(): JSX.Element;
}