Home / Function/ ensureRootIsScheduled() — react Function Reference

ensureRootIsScheduled() — react Function Reference

Architecture documentation for the ensureRootIsScheduled() function in ReactFiberRootScheduler.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  f9b5b565_a1d3_a66b_d9f2_1d956bf976f2["ensureRootIsScheduled()"]
  7f49f8c2_5f55_2b41_aead_a9cc24822373["ReactFiberRootScheduler.js"]
  f9b5b565_a1d3_a66b_d9f2_1d956bf976f2 -->|defined in| 7f49f8c2_5f55_2b41_aead_a9cc24822373
  5525b1e9_21ea_d865_cc52_ba860e27fc51["scheduleGesture()"]
  5525b1e9_21ea_d865_cc52_ba860e27fc51 -->|calls| f9b5b565_a1d3_a66b_d9f2_1d956bf976f2
  de881d63_fce3_732d_f977_91fae8626426["ensureScheduleIsScheduled()"]
  f9b5b565_a1d3_a66b_d9f2_1d956bf976f2 -->|calls| de881d63_fce3_732d_f977_91fae8626426
  style f9b5b565_a1d3_a66b_d9f2_1d956bf976f2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberRootScheduler.js lines 116–152

export function ensureRootIsScheduled(root: FiberRoot): void {
  // This function is called whenever a root receives an update. It does two
  // things 1) it ensures the root is in the root schedule, and 2) it ensures
  // there's a pending microtask to process the root schedule.
  //
  // Most of the actual scheduling logic does not happen until
  // `scheduleTaskForRootDuringMicrotask` runs.

  // Add the root to the schedule
  if (root === lastScheduledRoot || root.next !== null) {
    // Fast path. This root is already scheduled.
  } else {
    if (lastScheduledRoot === null) {
      firstScheduledRoot = lastScheduledRoot = root;
    } else {
      lastScheduledRoot.next = root;
      lastScheduledRoot = root;
    }
  }

  // Any time a root received an update, we set this to true until the next time
  // we process the schedule. If it's false, then we can quickly exit flushSync
  // without consulting the schedule.
  mightHavePendingSyncWork = true;

  ensureScheduleIsScheduled();

  if (
    __DEV__ &&
    !disableLegacyMode &&
    ReactSharedInternals.isBatchingLegacy &&
    root.tag === LegacyRoot
  ) {
    // Special `act` case: Record whenever a legacy update is scheduled.
    ReactSharedInternals.didScheduleLegacyUpdate = true;
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does ensureRootIsScheduled() do?
ensureRootIsScheduled() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberRootScheduler.js.
Where is ensureRootIsScheduled() defined?
ensureRootIsScheduled() is defined in packages/react-reconciler/src/ReactFiberRootScheduler.js at line 116.
What does ensureRootIsScheduled() call?
ensureRootIsScheduled() calls 1 function(s): ensureScheduleIsScheduled.
What calls ensureRootIsScheduled()?
ensureRootIsScheduled() is called by 1 function(s): scheduleGesture.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free