MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / commitRoot

Function commitRoot

code/one-direction-data-flow/public/app.js:12806–12918  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

12804 }
12805
12806 function commitRoot(finishedWork) {
12807 isWorking = true;
12808 isCommitting = true;
12809 startCommitTimer();
12810
12811 var root = finishedWork.stateNode;
12812 !(root.current !== finishedWork) ? invariant(false, 'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.') : void 0;
12813 var committedExpirationTime = root.pendingCommitExpirationTime;
12814 !(committedExpirationTime !== NoWork) ? invariant(false, 'Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
12815 root.pendingCommitExpirationTime = NoWork;
12816
12817 var currentTime = recalculateCurrentTime();
12818
12819 // Reset this to null before calling lifecycles
12820 ReactCurrentOwner.current = null;
12821
12822 var firstEffect = void 0;
12823 if (finishedWork.effectTag > PerformedWork) {
12824 // A fiber's effect list consists only of its children, not itself. So if
12825 // the root has an effect, we need to add it to the end of the list. The
12826 // resulting list is the set that would belong to the root's parent, if
12827 // it had one; that is, all the effects in the tree including the root.
12828 if (finishedWork.lastEffect !== null) {
12829 finishedWork.lastEffect.nextEffect = finishedWork;
12830 firstEffect = finishedWork.firstEffect;
12831 } else {
12832 firstEffect = finishedWork;
12833 }
12834 } else {
12835 // There is no effect on the root.
12836 firstEffect = finishedWork.firstEffect;
12837 }
12838
12839 prepareForCommit(root.containerInfo);
12840
12841 // Commit all the side-effects within a tree. We'll do this in two passes.
12842 // The first pass performs all the host insertions, updates, deletions and
12843 // ref unmounts.
12844 nextEffect = firstEffect;
12845 startCommitHostEffectsTimer();
12846 while (nextEffect !== null) {
12847 var didError = false;
12848 var error = void 0;
12849 {
12850 invokeGuardedCallback$2(null, commitAllHostEffects, null);
12851 if (hasCaughtError()) {
12852 didError = true;
12853 error = clearCaughtError();
12854 }
12855 }
12856 if (didError) {
12857 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
12858 onCommitPhaseError(nextEffect, error);
12859 // Clean-up
12860 if (nextEffect !== null) {
12861 nextEffect = nextEffect.nextEffect;
12862 }
12863 }

Callers 1

completeRootFunction · 0.70

Calls 10

startCommitTimerFunction · 0.70
invariantFunction · 0.70
recalculateCurrentTimeFunction · 0.70
onCommitPhaseErrorFunction · 0.70
stopCommitTimerFunction · 0.70
onCommitRootFunction · 0.70

Tested by

no test coverage detected