@@ -2697,10 +2697,12 @@ export class RouterCore<
2697
2697
this . getMatch ( matchId ) ,
2698
2698
loaderData ,
2699
2699
)
2700
- innerLoadContext . updateMatch ( matchId , ( prev ) => ( {
2701
- ...prev ,
2702
- loaderData,
2703
- } ) )
2700
+ if ( loaderData !== undefined ) {
2701
+ innerLoadContext . updateMatch ( matchId , ( prev ) => ( {
2702
+ ...prev ,
2703
+ loaderData,
2704
+ } ) )
2705
+ }
2704
2706
}
2705
2707
2706
2708
// Lazy option can modify the route options,
@@ -2837,14 +2839,18 @@ export class RouterCore<
2837
2839
)
2838
2840
: shouldReloadOption
2839
2841
2840
- innerLoadContext . updateMatch ( matchId , ( prev ) => {
2841
- prev . _nonReactive . loaderPromise = createControlledPromise < void > ( )
2842
- return {
2843
- ...prev ,
2844
- preload :
2845
- ! ! preload && ! this . state . matches . some ( ( d ) => d . id === matchId ) ,
2846
- }
2847
- } )
2842
+ const nextPreload =
2843
+ ! ! preload && ! this . state . matches . some ( ( d ) => d . id === matchId )
2844
+ const match = this . getMatch ( matchId ) !
2845
+ match . _nonReactive . loaderPromise = createControlledPromise < void > ( )
2846
+ if ( nextPreload !== match . preload ) {
2847
+ innerLoadContext . updateMatch ( matchId , ( prev ) => {
2848
+ return {
2849
+ ...prev ,
2850
+ preload : nextPreload ,
2851
+ }
2852
+ } )
2853
+ }
2848
2854
2849
2855
// If the route is successful and still fresh, just resolve
2850
2856
const { status, invalid } = this . getMatch ( matchId ) !
@@ -2886,23 +2892,26 @@ export class RouterCore<
2886
2892
}
2887
2893
}
2888
2894
}
2895
+ const match = this . getMatch ( matchId ) !
2889
2896
if ( ! loaderIsRunningAsync ) {
2890
- const match = this . getMatch ( matchId ) !
2891
2897
match . _nonReactive . loaderPromise ?. resolve ( )
2892
2898
match . _nonReactive . loadPromise ?. resolve ( )
2893
2899
}
2894
2900
2895
- innerLoadContext . updateMatch ( matchId , ( prev ) => {
2896
- clearTimeout ( prev . _nonReactive . pendingTimeout )
2897
- prev . _nonReactive . pendingTimeout = undefined
2898
- if ( ! loaderIsRunningAsync ) prev . _nonReactive . loaderPromise = undefined
2899
- prev . _nonReactive . dehydrated = undefined
2900
- return {
2901
- ...prev ,
2902
- isFetching : loaderIsRunningAsync ? prev . isFetching : false ,
2903
- invalid : false ,
2904
- }
2905
- } )
2901
+ clearTimeout ( match . _nonReactive . pendingTimeout )
2902
+ match . _nonReactive . pendingTimeout = undefined
2903
+ if ( ! loaderIsRunningAsync ) match . _nonReactive . loaderPromise = undefined
2904
+ match . _nonReactive . dehydrated = undefined
2905
+ const nextIsFetching = loaderIsRunningAsync ? match . isFetching : false
2906
+ if ( nextIsFetching !== match . isFetching || match . invalid !== false ) {
2907
+ innerLoadContext . updateMatch ( matchId , ( prev ) => {
2908
+ return {
2909
+ ...prev ,
2910
+ isFetching : nextIsFetching ,
2911
+ invalid : false ,
2912
+ }
2913
+ } )
2914
+ }
2906
2915
return this . getMatch ( matchId ) !
2907
2916
}
2908
2917
0 commit comments