File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
packages/react-router/lib/dom/ssr Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -585,30 +585,19 @@ function getShouldRevalidateFunction(
585585 // If users are somehow re-generating updated versions of these on the backend
586586 // they can still opt-into revalidation which will make the `.data` request
587587 if ( ! ssr && manifestRoute . hasLoader && ! manifestRoute . hasClientLoader ) {
588- let [ , params ] = path ? compilePath ( path ) : [ null , [ ] ] ;
589- let paramNames = params . map ( ( p ) => p . paramName ) ;
590- const getDefaultShouldRevalidate = ( {
591- currentParams,
592- nextParams,
593- } : ShouldRevalidateFunctionArgs ) => {
594- for ( let param of paramNames ) {
595- if ( currentParams [ param ] !== nextParams [ param ] ) {
596- return true ;
597- }
598- }
599- return false ;
600- } ;
588+ let myParams = path ? compilePath ( path ) [ 1 ] . map ( ( p ) => p . paramName ) : [ ] ;
589+ const didParamsChange = ( opts : ShouldRevalidateFunctionArgs ) =>
590+ myParams . some ( ( p ) => opts . currentParams [ p ] !== opts . nextParams [ p ] ) ;
601591
602592 if ( route . shouldRevalidate ) {
603593 let fn = route . shouldRevalidate ;
604594 return ( opts : ShouldRevalidateFunctionArgs ) =>
605595 fn ( {
606596 ...opts ,
607- defaultShouldRevalidate : getDefaultShouldRevalidate ( opts ) ,
597+ defaultShouldRevalidate : didParamsChange ( opts ) ,
608598 } ) ;
609599 } else {
610- return ( opts : ShouldRevalidateFunctionArgs ) =>
611- getDefaultShouldRevalidate ( opts ) ;
600+ return ( opts : ShouldRevalidateFunctionArgs ) => didParamsChange ( opts ) ;
612601 }
613602 }
614603
You can’t perform that action at this time.
0 commit comments