Skip to content

Commit

Permalink
Unify stack error
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 15, 2024
1 parent ba90061 commit 4e77339
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,6 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
if (typeof Dispatcher.useFormState === 'function') {
// This type check is for Flow only.
Dispatcher.useFormState((s: mixed, p: mixed) => s, null);
try {
// $FlowFixMe[not-a-function]: Already checked above.
Dispatcher.useFormState(
(s: mixed, p: mixed) => s,
// This isn't actually a valid call.
// We just simulate a pending promise here to exhaust all cases in the stackframe cache.
({
then() {},
}: any),
);
} catch (x) {}
}
if (typeof Dispatcher.use === 'function') {
// This type check is for Flow only.
Expand Down Expand Up @@ -504,6 +493,7 @@ function useFormState<S, P>(
): [Awaited<S>, (P) => void] {
const hook = nextHook(); // FormState
nextHook(); // ActionQueue
const stackError = new Error();
let state;
let debugInfo = null;
if (hook !== null) {
Expand Down Expand Up @@ -531,7 +521,7 @@ function useFormState<S, P>(
// but we can still emit anything up until this point.
hookLog.push({
primitive: 'FormState',
stackError: new Error(),
stackError: stackError,
value: thenable,
debugInfo:
thenable._debugInfo === undefined ? null : thenable._debugInfo,
Expand All @@ -546,7 +536,7 @@ function useFormState<S, P>(
}
hookLog.push({
primitive: 'FormState',
stackError: new Error(),
stackError: stackError,
value: state,
debugInfo: debugInfo,
});
Expand Down

0 comments on commit 4e77339

Please sign in to comment.