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

Function commitRoot

code/higher-order-components/public/app.js:12927–13039  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

12925 }
12926
12927 function commitRoot(finishedWork) {
12928 isWorking = true;
12929 isCommitting = true;
12930 startCommitTimer();
12931
12932 var root = finishedWork.stateNode;
12933 !(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;
12934 var committedExpirationTime = root.pendingCommitExpirationTime;
12935 !(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;
12936 root.pendingCommitExpirationTime = NoWork;
12937
12938 var currentTime = recalculateCurrentTime();
12939
12940 // Reset this to null before calling lifecycles
12941 ReactCurrentOwner.current = null;
12942
12943 var firstEffect = void 0;
12944 if (finishedWork.effectTag > PerformedWork) {
12945 // A fiber's effect list consists only of its children, not itself. So if
12946 // the root has an effect, we need to add it to the end of the list. The
12947 // resulting list is the set that would belong to the root's parent, if
12948 // it had one; that is, all the effects in the tree including the root.
12949 if (finishedWork.lastEffect !== null) {
12950 finishedWork.lastEffect.nextEffect = finishedWork;
12951 firstEffect = finishedWork.firstEffect;
12952 } else {
12953 firstEffect = finishedWork;
12954 }
12955 } else {
12956 // There is no effect on the root.
12957 firstEffect = finishedWork.firstEffect;
12958 }
12959
12960 prepareForCommit(root.containerInfo);
12961
12962 // Commit all the side-effects within a tree. We'll do this in two passes.
12963 // The first pass performs all the host insertions, updates, deletions and
12964 // ref unmounts.
12965 nextEffect = firstEffect;
12966 startCommitHostEffectsTimer();
12967 while (nextEffect !== null) {
12968 var didError = false;
12969 var error = void 0;
12970 {
12971 invokeGuardedCallback$2(null, commitAllHostEffects, null);
12972 if (hasCaughtError()) {
12973 didError = true;
12974 error = clearCaughtError();
12975 }
12976 }
12977 if (didError) {
12978 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
12979 onCommitPhaseError(nextEffect, error);
12980 // Clean-up
12981 if (nextEffect !== null) {
12982 nextEffect = nextEffect.nextEffect;
12983 }
12984 }

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