Skip to content

Commit 02e22a7

Browse files
committed
Clear caught error
This is not necessary (as proven by tests) because next invokeGuardedCallback clears it anyway. But I'll keep it for consistency with other calls.
1 parent 45884e9 commit 02e22a7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.new.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ import {
140140
} from './ReactHookEffectTags';
141141
import {didWarnAboutReassigningProps} from './ReactFiberBeginWork.new';
142142
import {doesFiberContain} from './ReactFiberTreeReflection';
143-
import {invokeGuardedCallback} from 'shared/ReactErrorUtils';
143+
import {invokeGuardedCallback, clearCaughtError} from 'shared/ReactErrorUtils';
144144

145145
let didWarnAboutUndefinedSnapshotBeforeUpdate: Set<mixed> | null = null;
146146
if (__DEV__) {
@@ -171,6 +171,7 @@ function reportUncaughtErrorInDEV(error) {
171171
invokeGuardedCallback(null, () => {
172172
throw error;
173173
});
174+
clearCaughtError();
174175
}
175176
}
176177

packages/react-reconciler/src/ReactFiberCommitWork.old.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ import {
140140
} from './ReactHookEffectTags';
141141
import {didWarnAboutReassigningProps} from './ReactFiberBeginWork.old';
142142
import {doesFiberContain} from './ReactFiberTreeReflection';
143-
import {invokeGuardedCallback} from 'shared/ReactErrorUtils';
143+
import {invokeGuardedCallback, clearCaughtError} from 'shared/ReactErrorUtils';
144144

145145
let didWarnAboutUndefinedSnapshotBeforeUpdate: Set<mixed> | null = null;
146146
if (__DEV__) {
@@ -171,6 +171,7 @@ function reportUncaughtErrorInDEV(error) {
171171
invokeGuardedCallback(null, () => {
172172
throw error;
173173
});
174+
clearCaughtError();
174175
}
175176
}
176177

0 commit comments

Comments
 (0)