UNPKG

@resourge/react-fetch

Version:

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

41 lines (40 loc) 1.4 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 VisitedUrl } from '../useOnScroll/types'; import { type ElementWithScrollTo } from '../useOnScroll/useOnScroll'; export interface InfiniteScrollRestoration { (behavior: ScrollBehavior): void; getPage: () => VisitedUrl; setPage: (page: number, perPage: number) => void; } /** * Method to restore scroll. * If return `ref` is not set, it will assume window * @param scrollRestorationId * @example * ```Typescript // useAction will probably be from a navigation/router package // Ex: import { useAction } from '@resourge/react-router'; const action = useAction(); // 'action' must be 'pop' for restoration to work; const [scrollRestoration, ref] = useInfiniteScrollRestoration(action); const {} = useInfiniteLoading( async () => { return HttpService.get("url") }, { initialState: [], scrollRestoration } ); ``` */ export declare const useInfiniteScrollRestoration: <T extends ElementWithScrollTo | null>(action: "pop" | string, scrollRestorationId?: string) => readonly [(behavior?: ScrollBehavior) => void, import("react").MutableRefObject<T>, (event: React.UIEvent<T, UIEvent>) => void];