From 88bbcf4bdd305994329a6b202474e2cc898c9cd8 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 2 Apr 2018 17:17:39 -0700 Subject: [PATCH] Extract throw to separate function so performUnitOfWork does not deopt Only affects DEV mode, but still important I think. --- packages/react-reconciler/src/ReactFiberScheduler.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index abd17a5979392..47fd98f69b65d 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -265,6 +265,7 @@ export default function( let replayUnitOfWork; let isReplayingFailedUnitOfWork; let originalReplayError; + let rethrowOriginalError; if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) { stashedWorkInProgressProperties = null; isReplayingFailedUnitOfWork = false; @@ -311,6 +312,9 @@ export default function( nextUnitOfWork = failedUnitOfWork; } }; + rethrowOriginalError = () => { + throw originalReplayError; + }; } function resetStack() { @@ -875,7 +879,7 @@ export default function( // 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) {