@@ -17,6 +17,7 @@ import type {
17
17
} from 'shared/ReactTypes' ;
18
18
import type {
19
19
ContextDependency ,
20
+ Dependencies ,
20
21
Fiber ,
21
22
Dispatcher as DispatcherType ,
22
23
} from 'react-reconciler/src/ReactInternalTypes' ;
@@ -33,6 +34,7 @@ import {
33
34
REACT_MEMO_CACHE_SENTINEL ,
34
35
REACT_CONTEXT_TYPE ,
35
36
} from 'shared/ReactSymbols' ;
37
+ import hasOwnProperty from 'shared/hasOwnProperty' ;
36
38
37
39
type CurrentDispatcherRef = typeof ReactSharedInternals . ReactCurrentDispatcher ;
38
40
@@ -157,7 +159,7 @@ function readContext<T>(context: ReactContext<T>): T {
157
159
} else {
158
160
if ( currentContextDependency === null ) {
159
161
throw new Error (
160
- 'Context reads do not line up with context dependencies. This is a bug in React.' ,
162
+ 'Context reads do not line up with context dependencies. This is a bug in React Debug Tools .' ,
161
163
) ;
162
164
}
163
165
@@ -1075,9 +1077,28 @@ export function inspectHooksOfFiber(
1075
1077
// current state from them.
1076
1078
currentHook = (fiber.memoizedState: Hook);
1077
1079
currentFiber = fiber;
1078
- const dependencies = currentFiber.dependencies;
1079
- currentContextDependency =
1080
- dependencies !== null ? dependencies.firstContext : null;
1080
+ if (hasOwnProperty.call(currentFiber, 'dependencies')) {
1081
+ // $FlowFixMe[incompatible-use]: Flow thinks hasOwnProperty might have nulled `currentFiber`
1082
+ const dependencies = currentFiber . dependencies ;
1083
+ currentContextDependency =
1084
+ dependencies !== null ? dependencies . firstContext : null ;
1085
+ } else if (hasOwnProperty.call(currentFiber, 'dependencies_old')) {
1086
+ const dependencies : Dependencies = ( currentFiber : any ) . dependencies_old ;
1087
+ currentContextDependency =
1088
+ dependencies !== null ? dependencies . firstContext : null ;
1089
+ } else if (hasOwnProperty.call(currentFiber, 'dependencies_new')) {
1090
+ const dependencies : Dependencies = ( currentFiber : any ) . dependencies_new ;
1091
+ currentContextDependency =
1092
+ dependencies !== null ? dependencies . firstContext : null ;
1093
+ } else if (hasOwnProperty.call(currentFiber, 'contextDependencies')) {
1094
+ const contextDependencies = ( currentFiber : any ) . contextDependencies ;
1095
+ currentContextDependency =
1096
+ contextDependencies !== null ? contextDependencies . first : null ;
1097
+ } else {
1098
+ throw new Error (
1099
+ 'Unsupported React version. This is a bug in React Debug Tools.' ,
1100
+ ) ;
1101
+ }
1081
1102
1082
1103
const type = fiber.type;
1083
1104
let props = fiber.memoizedProps;
0 commit comments