@tanstack/react-router
Version:
Modern and scalable routing for React applications
29 lines (28 loc) • 1.57 kB
text/typescript
import { AnyRouter, NonNullableUpdater, ParsedLocation } from '@tanstack/router-core';
export type ScrollRestorationEntry = {
scrollX: number;
scrollY: number;
};
export type ScrollRestorationByElement = Record<string, ScrollRestorationEntry>;
export type ScrollRestorationByKey = Record<string, ScrollRestorationByElement>;
export type ScrollRestorationCache = {
state: ScrollRestorationByKey;
set: (updater: NonNullableUpdater<ScrollRestorationByKey>) => void;
};
export type ScrollRestorationOptions = {
getKey?: (location: ParsedLocation) => string;
scrollBehavior?: ScrollToOptions['behavior'];
};
export declare const storageKey = "tsr-scroll-restoration-v1_3";
export declare const scrollRestorationCache: ScrollRestorationCache;
/**
* The default `getKey` function for `useScrollRestoration`.
* It returns the `key` from the location state or the `href` of the location.
*
* The `location.href` is used as a fallback to support the use case where the location state is not available like the initial render.
*/
export declare const defaultGetScrollRestorationKey: (location: ParsedLocation) => string;
export declare function getCssSelector(el: any): string;
export declare function restoreScroll(storageKey: string, key?: string, behavior?: ScrollToOptions['behavior'], shouldScrollRestoration?: boolean, scrollToTopSelectors?: Array<string>): void;
export declare function setupScrollRestoration(router: AnyRouter, force?: boolean): void;
export declare function ScrollRestoration(): import("react/jsx-runtime").JSX.Element | null;