@@ -77,7 +77,11 @@ export const useHref = (to: () => string | undefined) => {
7777export const useNavigate = ( ) => useRouter ( ) . navigatorFactory ( ) ;
7878export const useLocation = < S = unknown > ( ) => useRouter ( ) . location as Location < S > ;
7979export const useIsRouting = ( ) => useRouter ( ) . isRouting ;
80- export const usePreloadRoute = ( ) => useRouter ( ) . preloadRoute ;
80+ export const usePreloadRoute = ( ) => {
81+ const pre = useRouter ( ) . preloadRoute
82+ return ( url : string | URL , options : { preloadData ?: boolean } = { } ) =>
83+ pre ( url instanceof URL ? url : new URL ( url , mockBase ) , options . preloadData )
84+ }
8185
8286export const useMatch = < S extends string > ( path : ( ) => S , matchFilters ?: MatchFilters < S > ) => {
8387 const location = useLocation ( ) ;
@@ -470,7 +474,7 @@ export function createRouterContext(
470474 }
471475 }
472476
473- function preloadRoute ( url : URL , options : { preloadData ?: boolean } = { } ) {
477+ function preloadRoute ( url : URL , preloadData ?: boolean ) {
474478 const matches = getRouteMatches ( branches ( ) , url . pathname ) ;
475479 const prevIntent = intent ;
476480 intent = "preload" ;
@@ -481,7 +485,7 @@ export function createRouterContext(
481485 ( route . component as MaybePreloadableComponent ) . preload ! ( ) ;
482486 const { preload } = route ;
483487 inPreloadFn = true ;
484- options . preloadData &&
488+ preloadData &&
485489 preload &&
486490 runWithOwner ( getContext ! ( ) , ( ) =>
487491 preload ( {
0 commit comments