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

Function batchedUpdates

code/dependency-injection/public/app.js:3691–3715  ·  view source on GitHub ↗
(fn, bookkeeping)

Source from the content-addressed store, hash-verified

3689
3690var isBatching = false;
3691function batchedUpdates(fn, bookkeeping) {
3692 if (isBatching) {
3693 // If we are currently inside another batch, we need to wait until it
3694 // fully completes before restoring state.
3695 return fn(bookkeeping);
3696 }
3697 isBatching = true;
3698 try {
3699 return _batchedUpdates(fn, bookkeeping);
3700 } finally {
3701 // Here we wait until all updates have propagated, which is important
3702 // when using controlled components within layers:
3703 // https://github.com/facebook/react/issues/1698
3704 // Then we restore state of any controlled component.
3705 isBatching = false;
3706 var controlledComponentsHavePendingUpdates = needsStateRestore();
3707 if (controlledComponentsHavePendingUpdates) {
3708 // If a controlled event was fired, we may need to restore the state of
3709 // the DOM node back to the controlled value. This is necessary when React
3710 // bails out of the update without touching the DOM.
3711 _flushInteractiveUpdates();
3712 restoreStateIfNeeded();
3713 }
3714 }
3715}
3716
3717function interactiveUpdates(fn, a, b) {
3718 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