Extract throw to separate function so performUnitOfWork does not deopt (#12521)
Only affects DEV mode, but still important I think.
Andrew Clark committed
Apr 2, 2018 at 17:45 UTC
6f2ea73978168372f33a6dfad6c049afddc4aef3
1 file changed
+5
-1
packages/react-reconciler/src/ReactFiberScheduler.js
+5
-1
@@ -265,6 +265,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
265
let replayUnitOfWork;
266
let isReplayingFailedUnitOfWork;
267
let originalReplayError;
268
+ let rethrowOriginalError;
269
if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
270
stashedWorkInProgressProperties = null;
271
isReplayingFailedUnitOfWork = false;
@@ -311,6 +312,9 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
312
nextUnitOfWork = failedUnitOfWork;
313
}
314
};
315
+ rethrowOriginalError = () => {
316
+ throw originalReplayError;
317
+ };
318
}
319
320
function resetStack() {
@@ -875,7 +879,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
879
// because the render phase is meant to be idempotent, and it should
880
// have thrown again. Since it didn't, rethrow the original error, so
881
// React's internal stack is not misaligned.
878
- throw originalReplayError;
882
+ rethrowOriginalError();
883
}
884
}
885
if (__DEV__ && ReactFiberInstrumentation.debugTool) {