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

Function batchedUpdates

code/composition/public/app.js:3736–3760  ·  view source on GitHub ↗
(fn, bookkeeping)

Source from the content-addressed store, hash-verified

3734
3735var isBatching = false;
3736function batchedUpdates(fn, bookkeeping) {
3737 if (isBatching) {
3738 // If we are currently inside another batch, we need to wait until it
3739 // fully completes before restoring state.
3740 return fn(bookkeeping);
3741 }
3742 isBatching = true;
3743 try {
3744 return _batchedUpdates(fn, bookkeeping);
3745 } finally {
3746 // Here we wait until all updates have propagated, which is important
3747 // when using controlled components within layers:
3748 // https://github.com/facebook/react/issues/1698
3749 // Then we restore state of any controlled component.
3750 isBatching = false;
3751 var controlledComponentsHavePendingUpdates = needsStateRestore();
3752 if (controlledComponentsHavePendingUpdates) {
3753 // If a controlled event was fired, we may need to restore the state of
3754 // the DOM node back to the controlled value. This is necessary when React
3755 // bails out of the update without touching the DOM.
3756 _flushInteractiveUpdates();
3757 restoreStateIfNeeded();
3758 }
3759 }
3760}
3761
3762function interactiveUpdates(fn, a, b) {
3763 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