@tanstack/react-router
Version:
Modern and scalable routing for React applications
1 lines • 1.5 kB
Source Map (JSON)
{"version":3,"file":"useLocation.cjs","sources":["../../src/useLocation.tsx"],"sourcesContent":["import { useRouterState } from './useRouterState'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\n\nexport interface UseLocationBaseOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing extends boolean = boolean,\n> {\n select?: (\n state: RouterState<TRouter['routeTree']>['location'],\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLocationResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected\n ? RouterState<TRouter['routeTree']>['location']\n : TSelected\n\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLocationBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseLocationResult<TRouter, TSelected> {\n return useRouterState({\n select: (state: any) =>\n opts?.select ? opts.select(state.location) : state.location,\n } as any) as UseLocationResult<TRouter, TSelected>\n}\n"],"names":["useRouterState"],"mappings":";;;AA4BO,SAAS,YAKd,MAEuC;AACvC,SAAOA,8BAAe;AAAA,IACpB,QAAQ,CAAC,WACP,6BAAM,UAAS,KAAK,OAAO,MAAM,QAAQ,IAAI,MAAM;AAAA,EAAA,CAC/C;AACV;;"}