@@ -2274,10 +2274,6 @@ export class RouterCore<
22742274 return ! ! ( allPreload && ! this . state . matches . find ( ( d ) => d . id === matchId ) )
22752275 }
22762276
2277- if ( ! this . isServer && ! this . state . matches . length ) {
2278- triggerOnReady ( )
2279- }
2280-
22812277 const handleRedirectAndNotFound = ( match : AnyRouteMatch , err : any ) => {
22822278 if ( isResolvedRedirect ( err ) ) {
22832279 if ( ! err . reloadDocument ) {
@@ -2383,7 +2379,9 @@ export class RouterCore<
23832379 onReady &&
23842380 ! this . isServer &&
23852381 ! resolvePreload ( matchId ) &&
2386- ( route . options . loader || route . options . beforeLoad ) &&
2382+ ( route . options . loader ||
2383+ route . options . beforeLoad ||
2384+ routeNeedsPreload ( route ) ) &&
23872385 typeof pendingMs === 'number' &&
23882386 pendingMs !== Infinity &&
23892387 ( route . options . pendingComponent ??
@@ -2668,6 +2666,10 @@ export class RouterCore<
26682666 loaderData,
26692667 } )
26702668
2669+ // Last but not least, wait for the the components
2670+ // to be preloaded before we resolve the match
2671+ await route . _componentsPromise
2672+
26712673 updateMatch ( matchId , ( prev ) => ( {
26722674 ...prev ,
26732675 error : undefined ,
@@ -2710,10 +2712,6 @@ export class RouterCore<
27102712 router : this ,
27112713 match : this . getMatch ( matchId ) ! ,
27122714 } )
2713-
2714- // Last but not least, wait for the the components
2715- // to be preloaded before we resolve the match
2716- await route . _componentsPromise
27172715 } catch ( err ) {
27182716 updateMatch ( matchId , ( prev ) => ( {
27192717 ...prev ,
0 commit comments