@@ -21,8 +21,6 @@ import {
21
21
HostRoot ,
22
22
HostPortal ,
23
23
HostText ,
24
- Fragment ,
25
- SuspenseComponent ,
26
24
} from 'shared/ReactWorkTags' ;
27
25
import { NoEffect , Placement } from 'shared/ReactSideEffectTags' ;
28
26
@@ -115,33 +113,27 @@ export function findCurrentFiberUsingSlowPath(fiber: Fiber): Fiber | null {
115
113
// If we have two possible branches, we'll walk backwards up to the root
116
114
// to see what path the root points to. On the way we may hit one of the
117
115
// special cases and we'll deal with them.
118
- let a = fiber ;
119
- let b = alternate ;
116
+ let a : Fiber = fiber ;
117
+ let b : Fiber = alternate ;
120
118
while ( true ) {
121
119
let parentA = a . return ;
122
- let parentB = parentA ? parentA . alternate : null ;
123
- if ( ! parentA || ! parentB ) {
124
- // We're either at the root, or we're in a special Fragment
125
- // with no alternate, which is how Suspense (un)hiding works.
126
- let maybeSuspenseFragment = parentA || parentB ;
127
- if ( maybeSuspenseFragment && maybeSuspenseFragment . tag === Fragment ) {
128
- const maybeSuspense = maybeSuspenseFragment . return ;
129
- if (
130
- maybeSuspense &&
131
- maybeSuspense . tag === SuspenseComponent &&
132
- // If state isn't null, it timed out and we have two Fragment children.
133
- maybeSuspense . memoizedState !== null
134
- ) {
135
- parentA = maybeSuspense ;
136
- parentB = maybeSuspense ;
137
- a = maybeSuspenseFragment ;
138
- b = maybeSuspenseFragment ;
139
- } else {
140
- break ;
141
- }
142
- } else {
143
- break ;
120
+ if ( parentA === null ) {
121
+ // We're at the root.
122
+ break ;
123
+ }
124
+ let parentB = parentA . alternate ;
125
+ if ( parentB === null ) {
126
+ // There is no alternate. This is an unusual case. Currently, it only
127
+ // happens when a Suspense component is hidden. An extra fragment fiber
128
+ // is inserted in between the Suspense fiber and its children. Skip
129
+ // over this extra fragment fiber and proceed to the next parent.
130
+ const nextParent = parentA . return ;
131
+ if ( nextParent !== null ) {
132
+ a = b = nextParent ;
133
+ continue ;
144
134
}
135
+ // If there's no parent, we're at the root.
136
+ break ;
145
137
}
146
138
147
139
// If both copies of the parent fiber point to the same child, we can
0 commit comments