MCPcopy
hub / github.com/facebook/react / batchedUpdates

Function batchedUpdates

packages/react-reconciler/src/ReactFiberWorkLoop.js:1763–1787  ·  view source on GitHub ↗
(fn: A => R, a: A)

Source from the content-addressed store, hash-verified

1761}
1762
1763export function batchedUpdates<A, R>(fn: A => R, a: A): R {
1764 if (disableLegacyMode) {
1765 // batchedUpdates is a no-op now, but there's still some internal react-dom
1766 // code calling it, that we can't remove until we remove legacy mode.
1767 return fn(a);
1768 } else {
1769 const prevExecutionContext = executionContext;
1770 executionContext |= BatchedContext;
1771 try {
1772 return fn(a);
1773 } finally {
1774 executionContext = prevExecutionContext;
1775 // If there were legacy sync updates, flush them at the end of the outer
1776 // most batchedUpdates-like method.
1777 if (
1778 executionContext === NoContext &&
1779 // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
1780 !(__DEV__ && ReactSharedInternals.isBatchingLegacy)
1781 ) {
1782 resetRenderTimer();
1783 flushSyncWorkOnLegacyRootsOnly();
1784 }
1785 }
1786 }
1787}
1788
1789export function discreteUpdates<A, B, C, D, R>(
1790 fn: (A, B, C, D) => R,

Callers

nothing calls this directly

Calls 3

resetRenderTimerFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected