MCPcopy Create free account
hub / github.com/reactjs/react-rails / commitRootImpl

Function commitRootImpl

lib/assets/react-source/development/react.js:26080–26374  ·  view source on GitHub ↗
(root, renderPriorityLevel)

Source from the content-addressed store, hash-verified

26078 }
26079
26080 function commitRootImpl(root, renderPriorityLevel) {
26081 do {
26082 // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
26083 // means `flushPassiveEffects` will sometimes result in additional
26084 // passive effects. So we need to keep flushing in a loop until there are
26085 // no more pending effects.
26086 // TODO: Might be better if `flushPassiveEffects` did not automatically
26087 // flush synchronous work at the end, to avoid factoring hazards like this.
26088 flushPassiveEffects();
26089 } while (rootWithPendingPassiveEffects !== null);
26090
26091 flushRenderPhaseStrictModeWarningsInDEV();
26092
26093 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
26094 {
26095 throw Error( "Should not already be working." );
26096 }
26097 }
26098
26099 var finishedWork = root.finishedWork;
26100 var expirationTime = root.finishedExpirationTime;
26101
26102 if (finishedWork === null) {
26103 return null;
26104 }
26105
26106 root.finishedWork = null;
26107 root.finishedExpirationTime = NoWork;
26108
26109 if (!(finishedWork !== root.current)) {
26110 {
26111 throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." );
26112 }
26113 } // commitRoot never returns a continuation; it always finishes synchronously.
26114 // So we can clear these now to allow a new callback to be scheduled.
26115
26116
26117 root.callbackNode = null;
26118 root.callbackExpirationTime = NoWork;
26119 root.callbackPriority = NoPriority;
26120 root.nextKnownPendingLevel = NoWork;
26121 startCommitTimer(); // Update the first and last pending times on this root. The new first
26122 // pending time is whatever is left on the root fiber.
26123
26124 var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
26125 markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
26126
26127 if (root === workInProgressRoot) {
26128 // We can reset these now that they are finished.
26129 workInProgressRoot = null;
26130 workInProgress = null;
26131 renderExpirationTime$1 = NoWork;
26132 } // This indicates that the last root we worked on is not the same one that
26133 // we're committing now. This most commonly happens when a suspended root
26134 // times out.
26135 // Get the list of effects.
26136
26137

Callers

nothing calls this directly

Calls 15

flushPassiveEffectsFunction · 0.85
startCommitTimerFunction · 0.85
markRootFinishedAtTimeFunction · 0.85
pushInteractionsFunction · 0.85
prepareForCommitFunction · 0.85
invokeGuardedCallbackFunction · 0.85
hasCaughtErrorFunction · 0.85
clearCaughtErrorFunction · 0.85
captureCommitPhaseErrorFunction · 0.85

Tested by

no test coverage detected