(fn, bookkeeping)
| 3847 | |
| 3848 | var isBatching = false; |
| 3849 | function 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 | |
| 3875 | function interactiveUpdates(fn, a, b) { |
| 3876 | return _interactiveUpdates(fn, a, b); |
no test coverage detected