|
8 | 8 | */ |
9 | 9 |
|
10 | 10 | import type { |
| 11 | + Thenable, |
11 | 12 | ReactComponentInfo, |
12 | 13 | ReactDebugInfo, |
13 | 14 | ReactAsyncInfo, |
@@ -3045,6 +3046,39 @@ export function attach( |
3045 | 3046 | return null; |
3046 | 3047 | } |
3047 | 3048 |
|
| 3049 | + function trackDebugInfoFromUsedThenables(fiber: Fiber): void { |
| 3050 | + // If a Fiber called use() in DEV mode then we may have collected _debugThenableState on |
| 3051 | + // the dependencies. If so, then this will contain the thenables passed to use(). |
| 3052 | + // These won't have their debug info picked up by fiber._debugInfo since that just |
| 3053 | + // contains things suspending the children. We have to collect use() separately. |
| 3054 | + const dependencies = fiber.dependencies; |
| 3055 | + if (dependencies == null) { |
| 3056 | + return; |
| 3057 | + } |
| 3058 | + const thenableState = dependencies._debugThenableState; |
| 3059 | + if (thenableState == null) { |
| 3060 | + return; |
| 3061 | + } |
| 3062 | + // In DEV the thenableState is an inner object. |
| 3063 | + const usedThenables: any = thenableState.thenables || thenableState; |
| 3064 | + if (!Array.isArray(usedThenables)) { |
| 3065 | + return; |
| 3066 | + } |
| 3067 | + for (let i = 0; i < usedThenables.length; i++) { |
| 3068 | + const thenable: Thenable<mixed> = usedThenables[i]; |
| 3069 | + const debugInfo = thenable._debugInfo; |
| 3070 | + if (debugInfo) { |
| 3071 | + for (let j = 0; j < debugInfo.length; j++) { |
| 3072 | + const debugEntry = debugInfo[i]; |
| 3073 | + if (debugEntry.awaited) { |
| 3074 | + const asyncInfo: ReactAsyncInfo = (debugEntry: any); |
| 3075 | + insertSuspendedBy(asyncInfo); |
| 3076 | + } |
| 3077 | + } |
| 3078 | + } |
| 3079 | + } |
| 3080 | + } |
| 3081 | +
|
3048 | 3082 | function mountVirtualChildrenRecursively( |
3049 | 3083 | firstChild: Fiber, |
3050 | 3084 | lastChild: null | Fiber, // non-inclusive |
@@ -3262,6 +3296,8 @@ export function attach( |
3262 | 3296 | // because we don't want to highlight every host node inside of a newly mounted subtree. |
3263 | 3297 | } |
3264 | 3298 |
|
| 3299 | + trackDebugInfoFromUsedThenables(fiber); |
| 3300 | +
|
3265 | 3301 | if (fiber.tag === HostHoistable) { |
3266 | 3302 | const nearestInstance = reconcilingParent; |
3267 | 3303 | if (nearestInstance === null) { |
@@ -4040,6 +4076,8 @@ export function attach( |
4040 | 4076 | } |
4041 | 4077 | } |
4042 | 4078 | try { |
| 4079 | + trackDebugInfoFromUsedThenables(nextFiber); |
| 4080 | +
|
4043 | 4081 | if ( |
4044 | 4082 | nextFiber.tag === HostHoistable && |
4045 | 4083 | prevFiber.memoizedState !== nextFiber.memoizedState |
|
0 commit comments