@@ -38,18 +38,24 @@ import {
3838 canHydrateSuspenseInstance ,
3939 getNextHydratableSibling ,
4040 getFirstHydratableChild ,
41+ getFirstHydratableChildWithinContainer ,
42+ getFirstHydratableChildWithinSuspenseInstance ,
4143 hydrateInstance ,
4244 hydrateTextInstance ,
4345 hydrateSuspenseInstance ,
4446 getNextHydratableInstanceAfterSuspenseInstance ,
4547 shouldDeleteUnhydratedTailInstances ,
4648 didNotMatchHydratedContainerTextInstance ,
4749 didNotMatchHydratedTextInstance ,
48- didNotHydrateContainerInstance ,
50+ didNotHydrateInstanceWithinContainer ,
51+ didNotHydrateInstanceWithinSuspenseInstance ,
4952 didNotHydrateInstance ,
50- didNotFindHydratableContainerInstance ,
51- didNotFindHydratableContainerTextInstance ,
52- didNotFindHydratableContainerSuspenseInstance ,
53+ didNotFindHydratableInstanceWithinContainer ,
54+ didNotFindHydratableTextInstanceWithinContainer ,
55+ didNotFindHydratableSuspenseInstanceWithinContainer ,
56+ didNotFindHydratableInstanceWithinSuspenseInstance ,
57+ didNotFindHydratableTextInstanceWithinSuspenseInstance ,
58+ didNotFindHydratableSuspenseInstanceWithinSuspenseInstance ,
5359 didNotFindHydratableInstance ,
5460 didNotFindHydratableTextInstance ,
5561 didNotFindHydratableSuspenseInstance ,
@@ -78,8 +84,10 @@ function enterHydrationState(fiber: Fiber): boolean {
7884 return false ;
7985 }
8086
81- const parentInstance = fiber . stateNode . containerInfo ;
82- nextHydratableInstance = getFirstHydratableChild ( parentInstance ) ;
87+ const parentInstance : Container = fiber . stateNode . containerInfo ;
88+ nextHydratableInstance = getFirstHydratableChildWithinContainer (
89+ parentInstance ,
90+ ) ;
8391 hydrationParentFiber = fiber ;
8492 isHydrating = true ;
8593 return true ;
@@ -92,8 +100,10 @@ function reenterHydrationStateFromDehydratedSuspenseInstance(
92100 if ( ! supportsHydration ) {
93101 return false ;
94102 }
95- nextHydratableInstance = getNextHydratableSibling ( suspenseInstance ) ;
96- popToNextHostParent ( fiber ) ;
103+ nextHydratableInstance = getFirstHydratableChildWithinSuspenseInstance (
104+ suspenseInstance ,
105+ ) ;
106+ hydrationParentFiber = fiber ;
97107 isHydrating = true ;
98108 return true ;
99109}
@@ -105,7 +115,7 @@ function deleteHydratableInstance(
105115 if ( __DEV__ ) {
106116 switch ( returnFiber . tag ) {
107117 case HostRoot :
108- didNotHydrateContainerInstance (
118+ didNotHydrateInstanceWithinContainer (
109119 returnFiber . stateNode . containerInfo ,
110120 instance ,
111121 ) ;
@@ -118,6 +128,14 @@ function deleteHydratableInstance(
118128 instance ,
119129 ) ;
120130 break ;
131+ case SuspenseComponent :
132+ const suspenseState : SuspenseState = returnFiber . memoizedState ;
133+ if ( suspenseState . dehydrated !== null )
134+ didNotHydrateInstanceWithinSuspenseInstance (
135+ suspenseState . dehydrated ,
136+ instance ,
137+ ) ;
138+ break ;
121139 }
122140 }
123141
@@ -144,14 +162,23 @@ function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) {
144162 case HostComponent :
145163 const type = fiber . type ;
146164 const props = fiber . pendingProps ;
147- didNotFindHydratableContainerInstance ( parentContainer , type , props ) ;
165+ didNotFindHydratableInstanceWithinContainer (
166+ parentContainer ,
167+ type ,
168+ props ,
169+ ) ;
148170 break ;
149171 case HostText :
150172 const text = fiber . pendingProps ;
151- didNotFindHydratableContainerTextInstance ( parentContainer , text ) ;
173+ didNotFindHydratableTextInstanceWithinContainer (
174+ parentContainer ,
175+ text ,
176+ ) ;
152177 break ;
153178 case SuspenseComponent :
154- didNotFindHydratableContainerSuspenseInstance ( parentContainer ) ;
179+ didNotFindHydratableSuspenseInstanceWithinContainer (
180+ parentContainer ,
181+ ) ;
155182 break ;
156183 }
157184 break ;
@@ -191,6 +218,35 @@ function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) {
191218 }
192219 break ;
193220 }
221+ case SuspenseComponent : {
222+ const suspenseState : SuspenseState = returnFiber . memoizedState ;
223+ const parentInstance = suspenseState . dehydrated ;
224+ if ( parentInstance !== null )
225+ switch ( fiber . tag ) {
226+ case HostComponent :
227+ const type = fiber . type ;
228+ const props = fiber . pendingProps ;
229+ didNotFindHydratableInstanceWithinSuspenseInstance (
230+ parentInstance ,
231+ type ,
232+ props ,
233+ ) ;
234+ break ;
235+ case HostText :
236+ const text = fiber . pendingProps ;
237+ didNotFindHydratableTextInstanceWithinSuspenseInstance (
238+ parentInstance ,
239+ text ,
240+ ) ;
241+ break ;
242+ case SuspenseComponent :
243+ didNotFindHydratableSuspenseInstanceWithinSuspenseInstance (
244+ parentInstance ,
245+ ) ;
246+ break ;
247+ }
248+ break ;
249+ }
194250 default :
195251 return ;
196252 }
0 commit comments