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

Function commitRoot

code/event-handlers/public/app.js:12263–12375  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

12261 }
12262
12263 function commitRoot(finishedWork) {
12264 isWorking = true;
12265 isCommitting = true;
12266 startCommitTimer();
12267
12268 var root = finishedWork.stateNode;
12269 !(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;
12270 var committedExpirationTime = root.pendingCommitExpirationTime;
12271 !(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;
12272 root.pendingCommitExpirationTime = NoWork;
12273
12274 var currentTime = recalculateCurrentTime();
12275
12276 // Reset this to null before calling lifecycles
12277 ReactCurrentOwner.current = null;
12278
12279 var firstEffect = void 0;
12280 if (finishedWork.effectTag > PerformedWork) {
12281 // A fiber's effect list consists only of its children, not itself. So if
12282 // the root has an effect, we need to add it to the end of the list. The
12283 // resulting list is the set that would belong to the root's parent, if
12284 // it had one; that is, all the effects in the tree including the root.
12285 if (finishedWork.lastEffect !== null) {
12286 finishedWork.lastEffect.nextEffect = finishedWork;
12287 firstEffect = finishedWork.firstEffect;
12288 } else {
12289 firstEffect = finishedWork;
12290 }
12291 } else {
12292 // There is no effect on the root.
12293 firstEffect = finishedWork.firstEffect;
12294 }
12295
12296 prepareForCommit(root.containerInfo);
12297
12298 // Commit all the side-effects within a tree. We'll do this in two passes.
12299 // The first pass performs all the host insertions, updates, deletions and
12300 // ref unmounts.
12301 nextEffect = firstEffect;
12302 startCommitHostEffectsTimer();
12303 while (nextEffect !== null) {
12304 var didError = false;
12305 var error = void 0;
12306 {
12307 invokeGuardedCallback$2(null, commitAllHostEffects, null);
12308 if (hasCaughtError()) {
12309 didError = true;
12310 error = clearCaughtError();
12311 }
12312 }
12313 if (didError) {
12314 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
12315 onCommitPhaseError(nextEffect, error);
12316 // Clean-up
12317 if (nextEffect !== null) {
12318 nextEffect = nextEffect.nextEffect;
12319 }
12320 }

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