diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index e1750dd2d5..ec4c554182 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -321,6 +321,12 @@ export default function( recordEffect(); const effectTag = nextEffect.effectTag; + + if (effectTag & Snapshot) { + const current = nextEffect.alternate; + commitBeforeMutationLifeCycles(current, nextEffect); + } + if (effectTag & ContentReset) { commitResetTextContent(nextEffect); } @@ -378,22 +384,6 @@ export default function( } } - function commitBeforeMutationLifecycles() { - while (nextEffect !== null) { - const effectTag = nextEffect.effectTag; - - if (effectTag & Snapshot) { - recordEffect(); - const current = nextEffect.alternate; - commitBeforeMutationLifeCycles(current, nextEffect); - } - - // Don't cleanup effects yet; - // This will be done by commitAllLifeCycles() - nextEffect = nextEffect.nextEffect; - } - } - function commitAllLifeCycles( finishedRoot: FiberRoot, currentTime: ExpirationTime, @@ -501,41 +491,6 @@ export default function( prepareForCommit(root.containerInfo); - // Invoke instances of getSnapshotBeforeUpdate before mutation. - nextEffect = firstEffect; - // TODO Start new commit phase timer from ReactDebugFiberPerf - while (nextEffect !== null) { - let didError = false; - let error; - if (__DEV__) { - invokeGuardedCallback(null, commitBeforeMutationLifecycles, null); - if (hasCaughtError()) { - didError = true; - error = clearCaughtError(); - } - } else { - try { - commitBeforeMutationLifecycles(); - } catch (e) { - didError = true; - error = e; - } - } - if (didError) { - invariant( - nextEffect !== null, - 'Should have next effect. This error is likely caused by a bug ' + - 'in React. Please file an issue.', - ); - onCommitPhaseError(nextEffect, error); - // Clean-up - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - // TODO Stop new commit phase timer from ReactDebugFiberPerf - // Commit all the side-effects within a tree. We'll do this in two passes. // The first pass performs all the host insertions, updates, deletions and // ref unmounts.