MCPcopy Index your code
hub / github.com/react/react / flushSyncFromReconciler

Function flushSyncFromReconciler

packages/react-reconciler/src/ReactFiberWorkLoop.js:1815–1853  ·  view source on GitHub ↗
(fn: (() => R) | void)

Source from the content-addressed store, hash-verified

1813declare function flushSyncFromReconciler<R>(fn: () => R): R;
1814declare function flushSyncFromReconciler(void): void;
1815export function flushSyncFromReconciler<R>(fn: (() => R) | void): R | void {
1816 // In legacy mode, we flush pending passive effects at the beginning of the
1817 // next event, not at the end of the previous one.
1818 if (
1819 pendingEffectsStatus !== NO_PENDING_EFFECTS &&
1820 !disableLegacyMode &&
1821 pendingEffectsRoot.tag === LegacyRoot &&
1822 (executionContext & (RenderContext | CommitContext)) === NoContext
1823 ) {
1824 flushPendingEffects();
1825 }
1826
1827 const prevExecutionContext = executionContext;
1828 executionContext |= BatchedContext;
1829
1830 const prevTransition = ReactSharedInternals.T;
1831 const previousPriority = getCurrentUpdatePriority();
1832
1833 try {
1834 setCurrentUpdatePriority(DiscreteEventPriority);
1835 ReactSharedInternals.T = null;
1836 if (fn) {
1837 return fn();
1838 } else {
1839 return undefined;
1840 }
1841 } finally {
1842 setCurrentUpdatePriority(previousPriority);
1843 ReactSharedInternals.T = prevTransition;
1844
1845 executionContext = prevExecutionContext;
1846 // Flush the immediate callbacks that were scheduled during this batch.
1847 // Note that this will happen even if batchedUpdates is higher up
1848 // the stack.
1849 if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
1850 flushSyncWorkOnAllRoots();
1851 }
1852 }
1853}
1854
1855// If called outside of a render or commit will flush all sync work on all roots
1856// Returns whether the the call was during a render or not

Callers

nothing calls this directly

Calls 5

getCurrentUpdatePriorityFunction · 0.90
setCurrentUpdatePriorityFunction · 0.90
flushSyncWorkOnAllRootsFunction · 0.90
flushPendingEffectsFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected