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

Function scheduleUpdateOnFiber

lib/assets/react-source/development/react.js:24858–24917  ·  view source on GitHub ↗
(fiber, expirationTime)

Source from the content-addressed store, hash-verified

24856 return expirationTime;
24857 }
24858 function scheduleUpdateOnFiber(fiber, expirationTime) {
24859 checkForNestedUpdates();
24860 warnAboutRenderPhaseUpdatesInDEV(fiber);
24861 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
24862
24863 if (root === null) {
24864 warnAboutUpdateOnUnmountedFiberInDEV(fiber);
24865 return;
24866 }
24867
24868 checkForInterruption(fiber, expirationTime);
24869 recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
24870 // priority as an argument to that function and this one.
24871
24872 var priorityLevel = getCurrentPriorityLevel();
24873
24874 if (expirationTime === Sync) {
24875 if ( // Check if we're inside unbatchedUpdates
24876 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
24877 (executionContext & (RenderContext | CommitContext)) === NoContext) {
24878 // Register pending interactions on the root to avoid losing traced interaction data.
24879 schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
24880 // root inside of batchedUpdates should be synchronous, but layout updates
24881 // should be deferred until the end of the batch.
24882
24883 performSyncWorkOnRoot(root);
24884 } else {
24885 ensureRootIsScheduled(root);
24886 schedulePendingInteractions(root, expirationTime);
24887
24888 if (executionContext === NoContext) {
24889 // Flush the synchronous work now, unless we're already working or inside
24890 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
24891 // scheduleCallbackForFiber to preserve the ability to schedule a callback
24892 // without immediately flushing it. We only do this for user-initiated
24893 // updates, to preserve historical behavior of legacy mode.
24894 flushSyncCallbackQueue();
24895 }
24896 }
24897 } else {
24898 ensureRootIsScheduled(root);
24899 schedulePendingInteractions(root, expirationTime);
24900 }
24901
24902 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
24903 // discrete, even inside a discrete event.
24904 priorityLevel === UserBlockingPriority$1 || priorityLevel === ImmediatePriority)) {
24905 // This is the result of a discrete event. Track the lowest priority
24906 // discrete update per root so we can flush them early, if needed.
24907 if (rootsWithPendingDiscreteUpdates === null) {
24908 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
24909 } else {
24910 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
24911
24912 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
24913 rootsWithPendingDiscreteUpdates.set(root, expirationTime);
24914 }
24915 }

Callers

nothing calls this directly

Calls 11

checkForNestedUpdatesFunction · 0.85
checkForInterruptionFunction · 0.85
recordScheduleUpdateFunction · 0.85
getCurrentPriorityLevelFunction · 0.85
performSyncWorkOnRootFunction · 0.85
ensureRootIsScheduledFunction · 0.85
flushSyncCallbackQueueFunction · 0.85

Tested by

no test coverage detected