UNPKG

@tanstack/react-router

Version:

Modern and scalable routing for React applications

1 lines 1.63 kB
{"version":3,"file":"ScrollRestoration.cjs","names":[],"sources":["../../src/ScrollRestoration.tsx"],"sourcesContent":["import {\n getElementScrollRestorationEntry,\n setupScrollRestoration,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type {\n ParsedLocation,\n ScrollRestorationEntry,\n ScrollRestorationOptions,\n} from '@tanstack/router-core'\n\nfunction useScrollRestoration() {\n const router = useRouter()\n setupScrollRestoration(router, true)\n}\n\n/**\n * @deprecated Use the `scrollRestoration` router option instead.\n */\nexport function ScrollRestoration(_props: ScrollRestorationOptions) {\n useScrollRestoration()\n\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n \"The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead.\",\n )\n }\n\n return null\n}\n\nexport function useElementScrollRestoration(\n options: (\n | {\n id: string\n getElement?: () => Window | Element | undefined | null\n }\n | {\n id?: string\n getElement: () => Window | Element | undefined | null\n }\n ) & {\n getKey?: (location: ParsedLocation) => string\n },\n): ScrollRestorationEntry | undefined {\n useScrollRestoration()\n\n return getElementScrollRestorationEntry(useRouter(), options)\n}\n"],"mappings":";;;;AAWA,SAAS,uBAAuB;AAE9B,EAAA,GAAA,sBAAA,wBADe,kBAAA,WAAW,EACK,KAAK;;;;;AAMtC,SAAgB,kBAAkB,QAAkC;AAClE,uBAAsB;AAEtB,KAAA,QAAA,IAAA,aAA6B,cAC3B,SAAQ,KACN,wGACD;AAGH,QAAO;;AAGT,SAAgB,4BACd,SAYoC;AACpC,uBAAsB;AAEtB,SAAA,GAAA,sBAAA,kCAAwC,kBAAA,WAAW,EAAE,QAAQ"}