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

Function batchedUpdates

code/redux/public/app.js:3849–3873  ·  view source on GitHub ↗
(fn, bookkeeping)

Source from the content-addressed store, hash-verified

3847
3848var isBatching = false;
3849function batchedUpdates(fn, bookkeeping) {
3850 if (isBatching) {
3851 // If we are currently inside another batch, we need to wait until it
3852 // fully completes before restoring state.
3853 return fn(bookkeeping);
3854 }
3855 isBatching = true;
3856 try {
3857 return _batchedUpdates(fn, bookkeeping);
3858 } finally {
3859 // Here we wait until all updates have propagated, which is important
3860 // when using controlled components within layers:
3861 // https://github.com/facebook/react/issues/1698
3862 // Then we restore state of any controlled component.
3863 isBatching = false;
3864 var controlledComponentsHavePendingUpdates = needsStateRestore();
3865 if (controlledComponentsHavePendingUpdates) {
3866 // If a controlled event was fired, we may need to restore the state of
3867 // the DOM node back to the controlled value. This is necessary when React
3868 // bails out of the update without touching the DOM.
3869 _flushInteractiveUpdates();
3870 restoreStateIfNeeded();
3871 }
3872 }
3873}
3874
3875function interactiveUpdates(fn, a, b) {
3876 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