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

Function batchedUpdates

code/third-party/public/app.js:2831–2855  ·  view source on GitHub ↗
(fn, bookkeeping)

Source from the content-addressed store, hash-verified

2829
2830var isBatching = false;
2831function batchedUpdates(fn, bookkeeping) {
2832 if (isBatching) {
2833 // If we are currently inside another batch, we need to wait until it
2834 // fully completes before restoring state.
2835 return fn(bookkeeping);
2836 }
2837 isBatching = true;
2838 try {
2839 return _batchedUpdates(fn, bookkeeping);
2840 } finally {
2841 // Here we wait until all updates have propagated, which is important
2842 // when using controlled components within layers:
2843 // https://github.com/facebook/react/issues/1698
2844 // Then we restore state of any controlled component.
2845 isBatching = false;
2846 var controlledComponentsHavePendingUpdates = needsStateRestore();
2847 if (controlledComponentsHavePendingUpdates) {
2848 // If a controlled event was fired, we may need to restore the state of
2849 // the DOM node back to the controlled value. This is necessary when React
2850 // bails out of the update without touching the DOM.
2851 _flushInteractiveUpdates();
2852 restoreStateIfNeeded();
2853 }
2854 }
2855}
2856
2857function interactiveUpdates(fn, a, b) {
2858 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