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

Function batchedUpdates

code/communication/public/app.js:3633–3657  ·  view source on GitHub ↗
(fn, bookkeeping)

Source from the content-addressed store, hash-verified

3631
3632var isBatching = false;
3633function batchedUpdates(fn, bookkeeping) {
3634 if (isBatching) {
3635 // If we are currently inside another batch, we need to wait until it
3636 // fully completes before restoring state.
3637 return fn(bookkeeping);
3638 }
3639 isBatching = true;
3640 try {
3641 return _batchedUpdates(fn, bookkeeping);
3642 } finally {
3643 // Here we wait until all updates have propagated, which is important
3644 // when using controlled components within layers:
3645 // https://github.com/facebook/react/issues/1698
3646 // Then we restore state of any controlled component.
3647 isBatching = false;
3648 var controlledComponentsHavePendingUpdates = needsStateRestore();
3649 if (controlledComponentsHavePendingUpdates) {
3650 // If a controlled event was fired, we may need to restore the state of
3651 // the DOM node back to the controlled value. This is necessary when React
3652 // bails out of the update without touching the DOM.
3653 _flushInteractiveUpdates();
3654 restoreStateIfNeeded();
3655 }
3656 }
3657}
3658
3659function interactiveUpdates(fn, a, b) {
3660 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