@@ -17,6 +17,7 @@ import type {
1717} from 'shared/ReactTypes' ;
1818import type {
1919 ContextDependency ,
20+ Dependencies ,
2021 Fiber ,
2122 Dispatcher as DispatcherType ,
2223} from 'react-reconciler/src/ReactInternalTypes' ;
@@ -33,6 +34,7 @@ import {
3334 REACT_MEMO_CACHE_SENTINEL ,
3435 REACT_CONTEXT_TYPE ,
3536} from 'shared/ReactSymbols' ;
37+ import hasOwnProperty from '../../shared/hasOwnProperty' ;
3638
3739type CurrentDispatcherRef = typeof ReactSharedInternals . ReactCurrentDispatcher ;
3840
@@ -157,7 +159,7 @@ function readContext<T>(context: ReactContext<T>): T {
157159 } else {
158160 if ( currentContextDependency === null ) {
159161 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 .' ,
161163 ) ;
162164 }
163165
@@ -1075,9 +1077,26 @@ export function inspectHooksOfFiber(
10751077 // current state from them.
10761078 currentHook = (fiber.memoizedState: Hook);
10771079 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 ( 'Unsupported React version. This is a bug in React Debug Tools.' )
1099+ }
10811100
10821101 const type = fiber.type;
10831102 let props = fiber.memoizedProps;
0 commit comments