File tree 1 file changed +5
-16
lines changed
packages/react-router/lib/dom/ssr
1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -585,30 +585,19 @@ function getShouldRevalidateFunction(
585
585
// If users are somehow re-generating updated versions of these on the backend
586
586
// they can still opt-into revalidation which will make the `.data` request
587
587
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 ] ) ;
601
591
602
592
if ( route . shouldRevalidate ) {
603
593
let fn = route . shouldRevalidate ;
604
594
return ( opts : ShouldRevalidateFunctionArgs ) =>
605
595
fn ( {
606
596
...opts ,
607
- defaultShouldRevalidate : getDefaultShouldRevalidate ( opts ) ,
597
+ defaultShouldRevalidate : didParamsChange ( opts ) ,
608
598
} ) ;
609
599
} else {
610
- return ( opts : ShouldRevalidateFunctionArgs ) =>
611
- getDefaultShouldRevalidate ( opts ) ;
600
+ return ( opts : ShouldRevalidateFunctionArgs ) => didParamsChange ( opts ) ;
612
601
}
613
602
}
614
603
You can’t perform that action at this time.
0 commit comments