(fn, bookkeeping)
| 3596 | |
| 3597 | var isBatching = false; |
| 3598 | function batchedUpdates(fn, bookkeeping) { |
| 3599 | if (isBatching) { |
| 3600 | // If we are currently inside another batch, we need to wait until it |
| 3601 | // fully completes before restoring state. |
| 3602 | return fn(bookkeeping); |
| 3603 | } |
| 3604 | isBatching = true; |
| 3605 | try { |
| 3606 | return _batchedUpdates(fn, bookkeeping); |
| 3607 | } finally { |
| 3608 | // Here we wait until all updates have propagated, which is important |
| 3609 | // when using controlled components within layers: |
| 3610 | // https://github.com/facebook/react/issues/1698 |
| 3611 | // Then we restore state of any controlled component. |
| 3612 | isBatching = false; |
| 3613 | var controlledComponentsHavePendingUpdates = needsStateRestore(); |
| 3614 | if (controlledComponentsHavePendingUpdates) { |
| 3615 | // If a controlled event was fired, we may need to restore the state of |
| 3616 | // the DOM node back to the controlled value. This is necessary when React |
| 3617 | // bails out of the update without touching the DOM. |
| 3618 | _flushInteractiveUpdates(); |
| 3619 | restoreStateIfNeeded(); |
| 3620 | } |
| 3621 | } |
| 3622 | } |
| 3623 | |
| 3624 | function interactiveUpdates(fn, a, b) { |
| 3625 | return _interactiveUpdates(fn, a, b); |
no test coverage detected