Skip to content

Commit 0775186

Browse files
author
Sebastian Silbermann
committed
if-else
1 parent 2c0bdc8 commit 0775186

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,21 @@ function nextHook(): null | Hook {
152152
function readContext<T>(context: ReactContext<T>): T {
153153
if (currentFiber === null) {
154154
// Hook inspection without access to the Fiber tree
155-
// e.g. when filling the primitive stack cache or during `ReactDebugTools.inspectHooks()`.
155+
// e.g. when warming up the primitive stack cache or during `ReactDebugTools.inspectHooks()`.
156156
return context._currentValue;
157-
}
158-
if (currentContextDependency === null) {
159-
throw new Error(
160-
'Context reads do not line up with context dependencies. This is a bug in React.',
161-
);
162-
}
157+
} else {
158+
if (currentContextDependency === null) {
159+
throw new Error(
160+
'Context reads do not line up with context dependencies. This is a bug in React.',
161+
);
162+
}
163163

164-
// For now we don't expose readContext usage in the hooks debugging info.
165-
const value = ((currentContextDependency.memoizedValue: any): T);
166-
currentContextDependency = currentContextDependency.next;
164+
// For now we don't expose readContext usage in the hooks debugging info.
165+
const value = ((currentContextDependency.memoizedValue: any): T);
166+
currentContextDependency = currentContextDependency.next;
167167

168-
return value;
168+
return value;
169+
}
169170
}
170171

171172
const SuspenseException: mixed = new Error(

0 commit comments

Comments
 (0)