mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Extract throw to separate function so performUnitOfWork does not deopt (#12521)
Only affects DEV mode, but still important I think.
This commit is contained in:
1 parent
4ccf58a94d
commit
6f2ea73978
1 file changed
+5
-1
+5
-1
@@ -265,6 +265,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
let replayUnitOfWork;
|
||||
let isReplayingFailedUnitOfWork;
|
||||
let originalReplayError;
|
||||
let rethrowOriginalError;
|
||||
if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
||||
stashedWorkInProgressProperties = null;
|
||||
isReplayingFailedUnitOfWork = false;
|
||||
@@ -311,6 +312,9 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
nextUnitOfWork = failedUnitOfWork;
|
||||
}
|
||||
};
|
||||
rethrowOriginalError = () => {
|
||||
throw originalReplayError;
|
||||
};
|
||||
}
|
||||
|
||||
function resetStack() {
|
||||
@@ -875,7 +879,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
// because the render phase is meant to be idempotent, and it should
|
||||
// have thrown again. Since it didn't, rethrow the original error, so
|
||||
// React's internal stack is not misaligned.
|
||||
throw originalReplayError;
|
||||
rethrowOriginalError();
|
||||
}
|
||||
}
|
||||
if (__DEV__ && ReactFiberInstrumentation.debugTool) {
|
||||
|
||||
Reference in new issue
Block a user