Skip to content

Commit 978ab6a

Browse files
committed
Stash Thenable State on the Dependencies Object for Use By DevTools
1 parent e0a07e9 commit 978ab6a

File tree

4 files changed

+54
-17
lines changed

4 files changed

+54
-17
lines changed

packages/react-reconciler/src/ReactFiber.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,16 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
404404
workInProgress.dependencies =
405405
currentDependencies === null
406406
? null
407-
: {
408-
lanes: currentDependencies.lanes,
409-
firstContext: currentDependencies.firstContext,
410-
};
407+
: __DEV__
408+
? {
409+
lanes: currentDependencies.lanes,
410+
firstContext: currentDependencies.firstContext,
411+
_debugThenableState: currentDependencies._debugThenableState,
412+
}
413+
: {
414+
lanes: currentDependencies.lanes,
415+
firstContext: currentDependencies.firstContext,
416+
};
411417

412418
// These will be overridden during the parent's reconciliation
413419
workInProgress.sibling = current.sibling;
@@ -503,10 +509,16 @@ export function resetWorkInProgress(
503509
workInProgress.dependencies =
504510
currentDependencies === null
505511
? null
506-
: {
507-
lanes: currentDependencies.lanes,
508-
firstContext: currentDependencies.firstContext,
509-
};
512+
: __DEV__
513+
? {
514+
lanes: currentDependencies.lanes,
515+
firstContext: currentDependencies.firstContext,
516+
_debugThenableState: currentDependencies._debugThenableState,
517+
}
518+
: {
519+
lanes: currentDependencies.lanes,
520+
firstContext: currentDependencies.firstContext,
521+
};
510522

511523
if (enableProfilerTimer) {
512524
// Note: We don't reset the actualTime counts. It's useful to accumulate

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,18 @@ function finishRenderingHooks<Props, SecondArg>(
637637
): void {
638638
if (__DEV__) {
639639
workInProgress._debugHookTypes = hookTypesDev;
640+
// Stash the thenable state for use by DevTools.
641+
if (workInProgress.dependencies === null) {
642+
if (thenableState !== null) {
643+
workInProgress.dependencies = {
644+
lanes: NoLanes,
645+
firstContext: null,
646+
_debugThenableState: thenableState,
647+
};
648+
}
649+
} else {
650+
workInProgress.dependencies._debugThenableState = thenableState;
651+
}
640652
}
641653

642654
// We can assume the previous dispatcher is always this one, since we set it

packages/react-reconciler/src/ReactFiberNewContext.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,16 @@ function readContextForConsumer_withSelect<C>(
825825

826826
// This is the first dependency for this component. Create a new list.
827827
lastContextDependency = contextItem;
828-
consumer.dependencies = {
829-
lanes: NoLanes,
830-
firstContext: contextItem,
831-
};
828+
consumer.dependencies = __DEV__
829+
? {
830+
lanes: NoLanes,
831+
firstContext: contextItem,
832+
_debugThenableState: null,
833+
}
834+
: {
835+
lanes: NoLanes,
836+
firstContext: contextItem,
837+
};
832838
if (enableLazyContextPropagation) {
833839
consumer.flags |= NeedsPropagation;
834840
}
@@ -869,10 +875,16 @@ function readContextForConsumer<C>(
869875

870876
// This is the first dependency for this component. Create a new list.
871877
lastContextDependency = contextItem;
872-
consumer.dependencies = {
873-
lanes: NoLanes,
874-
firstContext: contextItem,
875-
};
878+
consumer.dependencies = __DEV__
879+
? {
880+
lanes: NoLanes,
881+
firstContext: contextItem,
882+
_debugThenableState: null,
883+
}
884+
: {
885+
lanes: NoLanes,
886+
firstContext: contextItem,
887+
};
876888
if (enableLazyContextPropagation) {
877889
consumer.flags |= NeedsPropagation;
878890
}

packages/react-reconciler/src/ReactInternalTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import type {
3737
} from './ReactFiberTracingMarkerComponent';
3838
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates';
3939
import type {ComponentStackNode} from 'react-server/src/ReactFizzComponentStack';
40+
import type {ThenableState} from './ReactFiberThenable';
4041

4142
// Unwind Circular: moved from ReactFiberHooks.old
4243
export type HookType =
@@ -81,7 +82,7 @@ export type Dependencies = {
8182
| ContextDependency<mixed>
8283
| ContextDependencyWithSelect<mixed>
8384
| null,
84-
...
85+
_debugThenableState?: null | ThenableState, // DEV-only
8586
};
8687

8788
export type MemoCache = {

0 commit comments

Comments
 (0)