flushSyncWorkAcrossRoots_impl() — react Function Reference
Architecture documentation for the flushSyncWorkAcrossRoots_impl() function in ReactFiberRootScheduler.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD b696b90a_5e97_f015_c2fa_f3bf0b69c0d2["flushSyncWorkAcrossRoots_impl()"] a22f22c8_f97a_86c8_be5a_4b91a6a21eab["ReactFiberRootScheduler.js"] b696b90a_5e97_f015_c2fa_f3bf0b69c0d2 -->|defined in| a22f22c8_f97a_86c8_be5a_4b91a6a21eab d39759e1_0993_8c5e_d6fb_971e55a17e03["flushSyncWorkOnAllRoots()"] d39759e1_0993_8c5e_d6fb_971e55a17e03 -->|calls| b696b90a_5e97_f015_c2fa_f3bf0b69c0d2 b695f033_78f9_2acd_a914_48242065304f["flushSyncWorkOnLegacyRootsOnly()"] b695f033_78f9_2acd_a914_48242065304f -->|calls| b696b90a_5e97_f015_c2fa_f3bf0b69c0d2 5e2a5e7b_8a85_c79d_5890_361c5a869d24["processRootScheduleInMicrotask()"] 5e2a5e7b_8a85_c79d_5890_361c5a869d24 -->|calls| b696b90a_5e97_f015_c2fa_f3bf0b69c0d2 9070656a_aeba_28ff_4921_4bcb0225f5c1["performSyncWorkOnRoot()"] b696b90a_5e97_f015_c2fa_f3bf0b69c0d2 -->|calls| 9070656a_aeba_28ff_4921_4bcb0225f5c1 style b696b90a_5e97_f015_c2fa_f3bf0b69c0d2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberRootScheduler.js lines 185–247
function flushSyncWorkAcrossRoots_impl(
syncTransitionLanes: Lanes | Lane,
onlyLegacy: boolean,
) {
if (isFlushingWork) {
// Prevent reentrancy.
// TODO: Is this overly defensive? The callers must check the execution
// context first regardless.
return;
}
if (!mightHavePendingSyncWork) {
// Fast path. There's no sync work to do.
return;
}
// There may or may not be synchronous work scheduled. Let's check.
let didPerformSomeWork;
isFlushingWork = true;
do {
didPerformSomeWork = false;
let root = firstScheduledRoot;
while (root !== null) {
if (onlyLegacy && (disableLegacyMode || root.tag !== LegacyRoot)) {
// Skip non-legacy roots.
} else {
if (syncTransitionLanes !== NoLanes) {
const nextLanes = getNextLanesToFlushSync(root, syncTransitionLanes);
if (nextLanes !== NoLanes) {
// This root has pending sync work. Flush it now.
didPerformSomeWork = true;
performSyncWorkOnRoot(root, nextLanes);
}
} else {
const workInProgressRoot = getWorkInProgressRoot();
const workInProgressRootRenderLanes =
getWorkInProgressRootRenderLanes();
const rootHasPendingCommit =
root.cancelPendingCommit !== null ||
root.timeoutHandle !== noTimeout;
const nextLanes = getNextLanes(
root,
root === workInProgressRoot
? workInProgressRootRenderLanes
: NoLanes,
rootHasPendingCommit,
);
if (
(includesSyncLane(nextLanes) ||
(enableGestureTransition && isGestureRender(nextLanes))) &&
!checkIfRootIsPrerendering(root, nextLanes)
) {
// This root has pending sync work. Flush it now.
didPerformSomeWork = true;
performSyncWorkOnRoot(root, nextLanes);
}
}
}
root = root.next;
}
} while (didPerformSomeWork);
isFlushingWork = false;
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does flushSyncWorkAcrossRoots_impl() do?
flushSyncWorkAcrossRoots_impl() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberRootScheduler.js.
Where is flushSyncWorkAcrossRoots_impl() defined?
flushSyncWorkAcrossRoots_impl() is defined in packages/react-reconciler/src/ReactFiberRootScheduler.js at line 185.
What does flushSyncWorkAcrossRoots_impl() call?
flushSyncWorkAcrossRoots_impl() calls 1 function(s): performSyncWorkOnRoot.
What calls flushSyncWorkAcrossRoots_impl()?
flushSyncWorkAcrossRoots_impl() is called by 3 function(s): flushSyncWorkOnAllRoots, flushSyncWorkOnLegacyRootsOnly, processRootScheduleInMicrotask.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free