MCPcopy Index your code
hub / github.com/microsoft/SandDance / scheduleUpdateOnFiber

Function scheduleUpdateOnFiber

docs/external/js/react-dom.development.js:21298–21357  ·  view source on GitHub ↗
(fiber, expirationTime)

Source from the content-addressed store, hash-verified

21296 return expirationTime;
21297 }
21298 function scheduleUpdateOnFiber(fiber, expirationTime) {
21299 checkForNestedUpdates();
21300 warnAboutRenderPhaseUpdatesInDEV(fiber);
21301 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
21302
21303 if (root === null) {
21304 warnAboutUpdateOnUnmountedFiberInDEV(fiber);
21305 return;
21306 }
21307
21308 checkForInterruption(fiber, expirationTime);
21309 recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
21310 // priority as an argument to that function and this one.
21311
21312 var priorityLevel = getCurrentPriorityLevel();
21313
21314 if (expirationTime === Sync) {
21315 if ( // Check if we're inside unbatchedUpdates
21316 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
21317 (executionContext & (RenderContext | CommitContext)) === NoContext) {
21318 // Register pending interactions on the root to avoid losing traced interaction data.
21319 schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
21320 // root inside of batchedUpdates should be synchronous, but layout updates
21321 // should be deferred until the end of the batch.
21322
21323 performSyncWorkOnRoot(root);
21324 } else {
21325 ensureRootIsScheduled(root);
21326 schedulePendingInteractions(root, expirationTime);
21327
21328 if (executionContext === NoContext) {
21329 // Flush the synchronous work now, unless we're already working or inside
21330 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
21331 // scheduleCallbackForFiber to preserve the ability to schedule a callback
21332 // without immediately flushing it. We only do this for user-initiated
21333 // updates, to preserve historical behavior of legacy mode.
21334 flushSyncCallbackQueue();
21335 }
21336 }
21337 } else {
21338 ensureRootIsScheduled(root);
21339 schedulePendingInteractions(root, expirationTime);
21340 }
21341
21342 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
21343 // discrete, even inside a discrete event.
21344 priorityLevel === UserBlockingPriority$1 || priorityLevel === ImmediatePriority)) {
21345 // This is the result of a discrete event. Track the lowest priority
21346 // discrete update per root so we can flush them early, if needed.
21347 if (rootsWithPendingDiscreteUpdates === null) {
21348 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
21349 } else {
21350 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
21351
21352 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
21353 rootsWithPendingDiscreteUpdates.set(root, expirationTime);
21354 }
21355 }

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected