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

Function finishConcurrentRender

lib/assets/react-source/development/react.js:25198–25417  ·  view source on GitHub ↗
(root, finishedWork, exitStatus, expirationTime)

Source from the content-addressed store, hash-verified

25196 }
25197
25198 function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
25199 // Set this to null to indicate there's no in-progress render.
25200 workInProgressRoot = null;
25201
25202 switch (exitStatus) {
25203 case RootIncomplete:
25204 case RootFatalErrored:
25205 {
25206 {
25207 {
25208 throw Error( "Root did not complete. This is a bug in React." );
25209 }
25210 }
25211 }
25212 // Flow knows about invariant, so it complains if I add a break
25213 // statement, but eslint doesn't know about invariant, so it complains
25214 // if I do. eslint-disable-next-line no-fallthrough
25215
25216 case RootErrored:
25217 {
25218 // If this was an async render, the error may have happened due to
25219 // a mutation in a concurrent event. Try rendering one more time,
25220 // synchronously, to see if the error goes away. If there are
25221 // lower priority updates, let's include those, too, in case they
25222 // fix the inconsistency. Render at Idle to include all updates.
25223 // If it was Idle or Never or some not-yet-invented time, render
25224 // at that time.
25225 markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime); // We assume that this second render pass will be synchronous
25226 // and therefore not hit this path again.
25227
25228 break;
25229 }
25230
25231 case RootSuspended:
25232 {
25233 markRootSuspendedAtTime(root, expirationTime);
25234 var lastSuspendedTime = root.lastSuspendedTime;
25235
25236 if (expirationTime === lastSuspendedTime) {
25237 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
25238 } // We have an acceptable loading state. We need to figure out if we
25239 // should immediately commit it or wait a bit.
25240 // If we have processed new updates during this render, we may now
25241 // have a new loading state ready. We want to ensure that we commit
25242 // that as soon as possible.
25243
25244
25245 var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
25246
25247 if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
25248 !( IsThisRendererActing.current)) {
25249 // If we have not processed any new updates during this pass, then
25250 // this is either a retry of an existing fallback state or a
25251 // hidden tree. Hidden trees shouldn't be batched with other work
25252 // and after that's fixed it can only be a retry. We're going to
25253 // throttle committing retries so that we don't show too many
25254 // loading states too quickly.
25255 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.

Callers 1

Calls 10

markRootExpiredAtTimeFunction · 0.85
markRootSuspendedAtTimeFunction · 0.85
prepareFreshStackFunction · 0.85
commitRootFunction · 0.85
expirationTimeToMsFunction · 0.85
jndFunction · 0.85

Tested by

no test coverage detected