(fn, bookkeeping)
| 3734 | |
| 3735 | var isBatching = false; |
| 3736 | function 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 | |
| 3762 | function interactiveUpdates(fn, a, b) { |
| 3763 | return _interactiveUpdates(fn, a, b); |
no test coverage detected