MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / batchedUpdates

Function batchedUpdates

code/higher-order-components/public/app.js:3592–3616  ·  view source on GitHub ↗
(fn, bookkeeping)

Source from the content-addressed store, hash-verified

3590
3591var isBatching = false;
3592function batchedUpdates(fn, bookkeeping) {
3593 if (isBatching) {
3594 // If we are currently inside another batch, we need to wait until it
3595 // fully completes before restoring state.
3596 return fn(bookkeeping);
3597 }
3598 isBatching = true;
3599 try {
3600 return _batchedUpdates(fn, bookkeeping);
3601 } finally {
3602 // Here we wait until all updates have propagated, which is important
3603 // when using controlled components within layers:
3604 // https://github.com/facebook/react/issues/1698
3605 // Then we restore state of any controlled component.
3606 isBatching = false;
3607 var controlledComponentsHavePendingUpdates = needsStateRestore();
3608 if (controlledComponentsHavePendingUpdates) {
3609 // If a controlled event was fired, we may need to restore the state of
3610 // the DOM node back to the controlled value. This is necessary when React
3611 // bails out of the update without touching the DOM.
3612 _flushInteractiveUpdates();
3613 restoreStateIfNeeded();
3614 }
3615 }
3616}
3617
3618function interactiveUpdates(fn, a, b) {
3619 return _interactiveUpdates(fn, a, b);

Callers 2

dispatchEventFunction · 0.70

Calls 5

_batchedUpdatesFunction · 0.70
needsStateRestoreFunction · 0.70
_flushInteractiveUpdatesFunction · 0.70
restoreStateIfNeededFunction · 0.70
performSyncWorkFunction · 0.70

Tested by

no test coverage detected