Skip to content

Commit

Permalink
if-else
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Mar 6, 2024
1 parent acfc7e8 commit 6580a4b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,21 @@ function nextHook(): null | Hook {
function readContext<T>(context: ReactContext<T>): T {
if (currentFiber === null) {
// Hook inspection without access to the Fiber tree
// e.g. when filling the primitive stack cache or during `ReactDebugTools.inspectHooks()`.
// e.g. when warming up the primitive stack cache or during `ReactDebugTools.inspectHooks()`.
return context._currentValue;
}
if (currentContextDependency === null) {
throw new Error(
'Context reads do not line up with context dependencies. This is a bug in React.',
);
}
} else {
if (currentContextDependency === null) {
throw new Error(
'Context reads do not line up with context dependencies. This is a bug in React.',
);
}

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

return value;
return value;
}
}

const SuspenseException: mixed = new Error(
Expand Down

0 comments on commit 6580a4b

Please sign in to comment.