@@ -38,18 +38,24 @@ import {
38
38
canHydrateSuspenseInstance ,
39
39
getNextHydratableSibling ,
40
40
getFirstHydratableChild ,
41
+ getFirstHydratableChildWithinContainer ,
42
+ getFirstHydratableChildWithinSuspenseInstance ,
41
43
hydrateInstance ,
42
44
hydrateTextInstance ,
43
45
hydrateSuspenseInstance ,
44
46
getNextHydratableInstanceAfterSuspenseInstance ,
45
47
shouldDeleteUnhydratedTailInstances ,
46
48
didNotMatchHydratedContainerTextInstance ,
47
49
didNotMatchHydratedTextInstance ,
48
- didNotHydrateContainerInstance ,
50
+ didNotHydrateInstanceWithinContainer ,
51
+ didNotHydrateInstanceWithinSuspenseInstance ,
49
52
didNotHydrateInstance ,
50
- didNotFindHydratableContainerInstance ,
51
- didNotFindHydratableContainerTextInstance ,
52
- didNotFindHydratableContainerSuspenseInstance ,
53
+ didNotFindHydratableInstanceWithinContainer ,
54
+ didNotFindHydratableTextInstanceWithinContainer ,
55
+ didNotFindHydratableSuspenseInstanceWithinContainer ,
56
+ didNotFindHydratableInstanceWithinSuspenseInstance ,
57
+ didNotFindHydratableTextInstanceWithinSuspenseInstance ,
58
+ didNotFindHydratableSuspenseInstanceWithinSuspenseInstance ,
53
59
didNotFindHydratableInstance ,
54
60
didNotFindHydratableTextInstance ,
55
61
didNotFindHydratableSuspenseInstance ,
@@ -78,8 +84,10 @@ function enterHydrationState(fiber: Fiber): boolean {
78
84
return false ;
79
85
}
80
86
81
- const parentInstance = fiber . stateNode . containerInfo ;
82
- nextHydratableInstance = getFirstHydratableChild ( parentInstance ) ;
87
+ const parentInstance : Container = fiber . stateNode . containerInfo ;
88
+ nextHydratableInstance = getFirstHydratableChildWithinContainer (
89
+ parentInstance ,
90
+ ) ;
83
91
hydrationParentFiber = fiber ;
84
92
isHydrating = true ;
85
93
return true ;
@@ -92,8 +100,10 @@ function reenterHydrationStateFromDehydratedSuspenseInstance(
92
100
if ( ! supportsHydration ) {
93
101
return false ;
94
102
}
95
- nextHydratableInstance = getNextHydratableSibling ( suspenseInstance ) ;
96
- popToNextHostParent ( fiber ) ;
103
+ nextHydratableInstance = getFirstHydratableChildWithinSuspenseInstance (
104
+ suspenseInstance ,
105
+ ) ;
106
+ hydrationParentFiber = fiber ;
97
107
isHydrating = true ;
98
108
return true ;
99
109
}
@@ -105,7 +115,7 @@ function deleteHydratableInstance(
105
115
if ( __DEV__ ) {
106
116
switch ( returnFiber . tag ) {
107
117
case HostRoot :
108
- didNotHydrateContainerInstance (
118
+ didNotHydrateInstanceWithinContainer (
109
119
returnFiber . stateNode . containerInfo ,
110
120
instance ,
111
121
) ;
@@ -118,6 +128,14 @@ function deleteHydratableInstance(
118
128
instance ,
119
129
) ;
120
130
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 ;
121
139
}
122
140
}
123
141
@@ -144,14 +162,23 @@ function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) {
144
162
case HostComponent :
145
163
const type = fiber . type ;
146
164
const props = fiber . pendingProps ;
147
- didNotFindHydratableContainerInstance ( parentContainer , type , props ) ;
165
+ didNotFindHydratableInstanceWithinContainer (
166
+ parentContainer ,
167
+ type ,
168
+ props ,
169
+ ) ;
148
170
break ;
149
171
case HostText :
150
172
const text = fiber . pendingProps ;
151
- didNotFindHydratableContainerTextInstance ( parentContainer , text ) ;
173
+ didNotFindHydratableTextInstanceWithinContainer (
174
+ parentContainer ,
175
+ text ,
176
+ ) ;
152
177
break ;
153
178
case SuspenseComponent :
154
- didNotFindHydratableContainerSuspenseInstance ( parentContainer ) ;
179
+ didNotFindHydratableSuspenseInstanceWithinContainer (
180
+ parentContainer ,
181
+ ) ;
155
182
break ;
156
183
}
157
184
break ;
@@ -191,6 +218,35 @@ function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) {
191
218
}
192
219
break ;
193
220
}
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
+ }
194
250
default :
195
251
return ;
196
252
}
0 commit comments