UNPKG

@resourge/react-fetch

Version:

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

31 lines (30 loc) 1.48 kB
/** * react-fetch v1.43.1 * * Copyright (c) resourge. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import { type PaginationConfig } from '../types/PaginationConfig'; import { type PaginationFunctionsType, type PaginationMethod } from '../types/PaginationFunctionsType'; import { type FilterSearchParamsReturn } from './useFilterSearchParams'; export type InfiniteLoadingReturn<Data extends any[], FilterSearchParams extends Record<string, any> = Record<string, any>> = FilterSearchParamsReturn<FilterSearchParams> & PaginationFunctionsType<Data, FilterSearchParams> & { readonly context: InfiniteLoadingReturn<Data, FilterSearchParams>; /** * If is last "page" */ isLast: boolean; /** * If last page is incomplete (itemPerPage 10 but the last page got less than 10) */ isLastIncomplete: boolean; loadMore: () => Promise<void>; /** * Preload method. */ preload: () => void; }; export declare const useInfiniteLoading: <Data extends any[], FilterSearchParams extends Record<string, any> = Record<string, any>>(method: PaginationMethod<Data, FilterSearchParams>, { initialState, filter: defaultFilter, sort: defaultSort, hash, deps, initialPage, initialPerPage, scrollRestoration, preload, fId, enable, ...config }: PaginationConfig<Data, FilterSearchParams>) => InfiniteLoadingReturn<Data, FilterSearchParams>;