if (isRendering) { // Prevent reentrancy. Remaining work will be scheduled at the end of // the currently rendering batch. return; }
if (isBatchingUpdates) { // Flush work at the end of the batch. if (isUnbatchingUpdates) { // ...unless we're inside unbatchedUpdates, in which case we should // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; performWorkOnRoot(root, Sync, false); }
return; } // TODO: Get rid of Sync and use current time?
functionperformWorkOnRoot(root, expirationTime, isYieldy) { !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void0; isRendering = true; ... }
functioncomputeExpirationForFiber(currentTime, fiber) { var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(); var expirationTime = void0;
if ((fiber.mode & ConcurrentMode) === NoContext) { // Outside of concurrent mode, updates are always synchronous. expirationTime = Sync; } elseif (isWorking && !isCommitting$1) { // During render phase, updates expire during as the current render. expirationTime = nextRenderExpirationTime; } else { switch (priorityLevel) { case scheduler.unstable_ImmediatePriority: expirationTime = Sync; break;
case scheduler.unstable_UserBlockingPriority: expirationTime = computeInteractiveExpiration(currentTime); break;
case scheduler.unstable_NormalPriority: // This is a normal, concurrent update expirationTime = computeAsyncExpiration(currentTime); break;
case scheduler.unstable_LowPriority: case scheduler.unstable_IdlePriority: expirationTime = Never; break;
default: invariant( false, "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." ); } // If we're in the middle of rendering a tree, do not update at the same // expiration time that is already rendering.
if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { expirationTime -= 1; } } // Keep track of the lowest pending interactive expiration time. This // allows us to synchronously flush all interactive updates // when needed. // TODO: Move this to renderer?