@@ -261,6 +261,8 @@ function tryHydrate(fiber, nextInstance) {
261
261
const instance = canHydrateInstance ( nextInstance , type , props ) ;
262
262
if ( instance !== null ) {
263
263
fiber . stateNode = ( instance : Instance ) ;
264
+ hydrationParentFiber = fiber ;
265
+ nextHydratableInstance = getFirstHydratableChild ( instance ) ;
264
266
return true ;
265
267
}
266
268
return false ;
@@ -270,6 +272,9 @@ function tryHydrate(fiber, nextInstance) {
270
272
const textInstance = canHydrateTextInstance ( nextInstance , text ) ;
271
273
if ( textInstance !== null ) {
272
274
fiber . stateNode = ( textInstance : TextInstance ) ;
275
+ hydrationParentFiber = fiber ;
276
+ // Text Instances don't have children so there's nothing to hydrate.
277
+ nextHydratableInstance = null ;
273
278
return true ;
274
279
}
275
280
return false ;
@@ -294,6 +299,10 @@ function tryHydrate(fiber, nextInstance) {
294
299
) ;
295
300
dehydratedFragment . return = fiber ;
296
301
fiber . child = dehydratedFragment ;
302
+ hydrationParentFiber = fiber ;
303
+ // While a Suspense Instance does have children, we won't step into
304
+ // it during the first pass. Instead, we'll reenter it later.
305
+ nextHydratableInstance = null ;
297
306
return true ;
298
307
}
299
308
}
@@ -322,6 +331,7 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
322
331
// We use this as a heuristic. It's based on intuition and not data so it
323
332
// might be flawed or unnecessary.
324
333
nextInstance = getNextHydratableSibling ( firstAttemptedInstance ) ;
334
+ const prevHydrationParentFiber : Fiber = ( hydrationParentFiber : any ) ;
325
335
if ( ! nextInstance || ! tryHydrate ( fiber , nextInstance ) ) {
326
336
// Nothing to hydrate. Make it an insertion.
327
337
insertNonHydratedInstance ( ( hydrationParentFiber : any ) , fiber ) ;
@@ -333,13 +343,8 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
333
343
// superfluous and we'll delete it. Since we can't eagerly delete it
334
344
// we'll have to schedule a deletion. To do that, this node needs a dummy
335
345
// fiber associated with it.
336
- deleteHydratableInstance (
337
- ( hydrationParentFiber : any ) ,
338
- firstAttemptedInstance ,
339
- ) ;
346
+ deleteHydratableInstance ( prevHydrationParentFiber , firstAttemptedInstance ) ;
340
347
}
341
- hydrationParentFiber = fiber ;
342
- nextHydratableInstance = getFirstHydratableChild ( ( nextInstance : any ) ) ;
343
348
}
344
349
345
350
function prepareToHydrateHostInstance (
0 commit comments