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:
Andrew Clark authored and Dan Abramov committed 2018-04-03 01:45:52 +01:00
1 parent 4ccf58a94d
commit 6f2ea73978
1 file changed
+5 -1
+5 -1
View File
@@ -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) {