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

Function commitRoot

code/styling/public/app.js:12933–13045  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

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

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