@@ -524,7 +524,7 @@ type BaseNavigateOrFetchOptions = {
524524 preventScrollReset ?: boolean ;
525525 relative ?: RelativeRoutingType ;
526526 flushSync ?: boolean ;
527- shouldRevalidate ?: boolean | ( ( ) => boolean ) ;
527+ defaultShouldRevalidate ?: boolean ;
528528} ;
529529
530530// Only allowed for navigations
@@ -2366,13 +2366,8 @@ export function createRouter(init: RouterInit): Router {
23662366 let preventScrollReset = ( opts && opts . preventScrollReset ) === true ;
23672367
23682368 if ( submission && isMutationMethod ( submission . formMethod ) ) {
2369- let shouldRevalidate =
2370- opts && "shouldRevalidate" in opts
2371- ? typeof opts . shouldRevalidate === "function"
2372- ? opts . shouldRevalidate ( )
2373- : // undefined should eval to true
2374- opts . shouldRevalidate !== false
2375- : true ;
2369+ let callSiteDefaultShouldRevalidate =
2370+ opts ?. defaultShouldRevalidate !== false ;
23762371 await handleFetcherAction (
23772372 key ,
23782373 routeId ,
@@ -2383,7 +2378,7 @@ export function createRouter(init: RouterInit): Router {
23832378 flushSync ,
23842379 preventScrollReset ,
23852380 submission ,
2386- shouldRevalidate ,
2381+ callSiteDefaultShouldRevalidate ,
23872382 ) ;
23882383 return ;
23892384 }
@@ -2401,6 +2396,7 @@ export function createRouter(init: RouterInit): Router {
24012396 flushSync ,
24022397 preventScrollReset ,
24032398 submission ,
2399+ // defaultShouldRevalidate, // todo
24042400 ) ;
24052401 }
24062402
@@ -2416,7 +2412,7 @@ export function createRouter(init: RouterInit): Router {
24162412 flushSync : boolean ,
24172413 preventScrollReset : boolean ,
24182414 submission : Submission ,
2419- shouldRevalidate : boolean ,
2415+ callSiteDefaultShouldRevalidate : boolean ,
24202416 ) {
24212417 interruptActiveLoads ( ) ;
24222418 fetchLoadMatches . delete ( key ) ;
@@ -2592,7 +2588,7 @@ export function createRouter(init: RouterInit): Router {
25922588 basename ,
25932589 init . patchRoutesOnNavigation != null ,
25942590 [ match . route . id , actionResult ] ,
2595- shouldRevalidate ,
2591+ callSiteDefaultShouldRevalidate ,
25962592 ) ;
25972593
25982594 // Put all revalidating fetchers into the loading state, except for the
@@ -2624,15 +2620,6 @@ export function createRouter(init: RouterInit): Router {
26242620 abortPendingFetchRevalidations ,
26252621 ) ;
26262622
2627- if ( ! shouldRevalidate ) {
2628- if ( state . fetchers . has ( key ) ) {
2629- let doneFetcher = getDoneFetcher ( actionResult . data ) ;
2630- state . fetchers . set ( key , doneFetcher ) ;
2631- }
2632- fetchControllers . delete ( key ) ;
2633- return ;
2634- }
2635-
26362623 let { loaderResults, fetcherResults } =
26372624 await callLoadersAndMaybeResolveData (
26382625 dsMatches ,
@@ -4859,7 +4846,7 @@ function getMatchesToLoad(
48594846 basename : string | undefined ,
48604847 hasPatchRoutesOnNavigation : boolean ,
48614848 pendingActionResult ?: PendingActionResult ,
4862- shouldRevalidate ?: boolean ,
4849+ callSiteDefaultShouldRevalidate ?: boolean ,
48634850) : {
48644851 dsMatches : DataStrategyMatch [ ] ;
48654852 revalidatingFetchers : RevalidatingFetcher [ ] ;
@@ -4896,7 +4883,8 @@ function getMatchesToLoad(
48964883 ? pendingActionResult [ 1 ] . statusCode
48974884 : undefined ;
48984885 let shouldSkipRevalidation =
4899- ( actionStatus && actionStatus >= 400 ) || shouldRevalidate === false ;
4886+ ( actionStatus && actionStatus >= 400 ) ||
4887+ callSiteDefaultShouldRevalidate === false ;
49004888
49014889 let baseShouldRevalidateArgs = {
49024890 currentUrl,
@@ -4949,7 +4937,6 @@ function getMatchesToLoad(
49494937 forceShouldLoad ,
49504938 ) ;
49514939 }
4952-
49534940 // This is the default implementation for when we revalidate. If the route
49544941 // provides it's own implementation, then we give them full control but
49554942 // provide this value so they can leverage it if needed after they check
0 commit comments