|
8 | 8 | */ |
9 | 9 |
|
10 | 10 | import type { |
| 11 | + Thenable, |
11 | 12 | ReactComponentInfo, |
12 | 13 | ReactDebugInfo, |
13 | 14 | ReactAsyncInfo, |
@@ -3181,6 +3182,39 @@ export function attach( |
3181 | 3182 | } |
3182 | 3183 | } |
3183 | 3184 |
|
| 3185 | + function trackDebugInfoFromUsedThenables(fiber: Fiber): void { |
| 3186 | + // If a Fiber called use() in DEV mode then we may have collected _debugThenableState on |
| 3187 | + // the dependencies. If so, then this will contain the thenables passed to use(). |
| 3188 | + // These won't have their debug info picked up by fiber._debugInfo since that just |
| 3189 | + // contains things suspending the children. We have to collect use() separately. |
| 3190 | + const dependencies = fiber.dependencies; |
| 3191 | + if (dependencies == null) { |
| 3192 | + return; |
| 3193 | + } |
| 3194 | + const thenableState = dependencies._debugThenableState; |
| 3195 | + if (thenableState == null) { |
| 3196 | + return; |
| 3197 | + } |
| 3198 | + // In DEV the thenableState is an inner object. |
| 3199 | + const usedThenables: any = thenableState.thenables || thenableState; |
| 3200 | + if (!Array.isArray(usedThenables)) { |
| 3201 | + return; |
| 3202 | + } |
| 3203 | + for (let i = 0; i < usedThenables.length; i++) { |
| 3204 | + const thenable: Thenable<mixed> = usedThenables[i]; |
| 3205 | + const debugInfo = thenable._debugInfo; |
| 3206 | + if (debugInfo) { |
| 3207 | + for (let j = 0; j < debugInfo.length; j++) { |
| 3208 | + const debugEntry = debugInfo[i]; |
| 3209 | + if (debugEntry.awaited) { |
| 3210 | + const asyncInfo: ReactAsyncInfo = (debugEntry: any); |
| 3211 | + insertSuspendedBy(asyncInfo); |
| 3212 | + } |
| 3213 | + } |
| 3214 | + } |
| 3215 | + } |
| 3216 | + } |
| 3217 | +
|
3184 | 3218 | function mountVirtualChildrenRecursively( |
3185 | 3219 | firstChild: Fiber, |
3186 | 3220 | lastChild: null | Fiber, // non-inclusive |
@@ -3400,6 +3434,7 @@ export function attach( |
3400 | 3434 | } |
3401 | 3435 |
|
3402 | 3436 | trackDebugInfoFromLazyType(fiber); |
| 3437 | + trackDebugInfoFromUsedThenables(fiber); |
3403 | 3438 |
|
3404 | 3439 | if (fiber.tag === HostHoistable) { |
3405 | 3440 | const nearestInstance = reconcilingParent; |
@@ -4231,6 +4266,7 @@ export function attach( |
4231 | 4266 | } |
4232 | 4267 | try { |
4233 | 4268 | trackDebugInfoFromLazyType(nextFiber); |
| 4269 | + trackDebugInfoFromUsedThenables(nextFiber); |
4234 | 4270 |
|
4235 | 4271 | if ( |
4236 | 4272 | nextFiber.tag === HostHoistable && |
|
0 commit comments