@@ -30,8 +30,9 @@ const SceneRSCView = ({active, name, refetch: serverRefetch, errorFallback, chil
30
30
if ( ! rscCache . get ( navigationEvent ) ) rscCache . set ( navigationEvent , { } ) ;
31
31
const cachedSceneViews = rscCache . get ( navigationEvent ) ;
32
32
const renderedSceneView = useRef ( { sceneView : undefined , navigationEvent : undefined } ) ;
33
- const dataChanged = ( ( ) => {
33
+ const fetching = ( ( ) => {
34
34
const refetch = refetchRef . current ;
35
+ if ( ! show ) return false ;
35
36
if ( ! getShow ( oldState ?. key ) || ! refetch || ignoreCache ) return true ;
36
37
if ( oldUrl && oldUrl . split ( 'crumb=' ) . length - 1 !== crumbs . length ) return true ;
37
38
if ( typeof refetch === 'function' ) return refetch ( stateContext ) ;
@@ -48,7 +49,7 @@ const SceneRSCView = ({active, name, refetch: serverRefetch, errorFallback, chil
48
49
if ( Object . keys ( cachedSceneViews ) . length <= 1 ) rscCache . delete ( navigationEvent ) ;
49
50
} ;
50
51
} , [ ] )
51
- if ( ! cachedSceneViews [ sceneViewKey ] && ! cachedHistory && ! firstScene && show && ! ancestorFetching && dataChanged ) {
52
+ if ( ! cachedSceneViews [ sceneViewKey ] && ! cachedHistory && ! firstScene && ! ancestorFetching && fetching ) {
52
53
cachedSceneViews [ sceneViewKey ] = deserialize ( historyManager . getHref ( url ) , {
53
54
method : 'post' ,
54
55
headers : { 'Content-Type' : 'application/json' } ,
@@ -59,7 +60,7 @@ const SceneRSCView = ({active, name, refetch: serverRefetch, errorFallback, chil
59
60
if ( ! show ) return null ;
60
61
if ( cachedHistory ) return historyCache [ url ] [ sceneViewKey ] ;
61
62
if ( firstScene || ancestorFetching ) return children ;
62
- if ( dataChanged ) return cachedSceneViews [ sceneViewKey ] ;
63
+ if ( fetching ) return cachedSceneViews [ sceneViewKey ] ;
63
64
return renderedSceneView . current . sceneView ;
64
65
} ) ( ) ;
65
66
useEffect ( ( ) => {
@@ -91,10 +92,10 @@ const SceneRSCView = ({active, name, refetch: serverRefetch, errorFallback, chil
91
92
window . addEventListener ( 'popstate' , cacheHistory ) ;
92
93
return ( ) => window . removeEventListener ( 'popstate' , cacheHistory ) ;
93
94
} ) ;
94
- const fetching = ancestorFetching || dataChanged ;
95
- const rscContextVal = useMemo ( ( ) => (
96
- { fetching , setRefetch : ( refetch : any ) => refetchRef . current = refetch !== undefined ? refetch : serverRefetch }
97
- ) , [ fetching ] ) ;
95
+ const rscContextVal = useMemo ( ( ) => ( {
96
+ fetching : ancestorFetching || fetching ,
97
+ setRefetch : ( refetch : any ) => refetchRef . current = refetch !== undefined ? refetch : serverRefetch
98
+ } ) , [ ancestorFetching || fetching ] ) ;
98
99
return (
99
100
< ErrorBoundary errorFallback = { errorFallback } >
100
101
< RSCContext . Provider value = { rscContextVal } >
0 commit comments