(fn, bookkeeping)
| 2920 | |
| 2921 | var isBatching = false; |
| 2922 | function batchedUpdates(fn, bookkeeping) { |
| 2923 | if (isBatching) { |
| 2924 | // If we are currently inside another batch, we need to wait until it |
| 2925 | // fully completes before restoring state. |
| 2926 | return fn(bookkeeping); |
| 2927 | } |
| 2928 | isBatching = true; |
| 2929 | try { |
| 2930 | return _batchedUpdates(fn, bookkeeping); |
| 2931 | } finally { |
| 2932 | // Here we wait until all updates have propagated, which is important |
| 2933 | // when using controlled components within layers: |
| 2934 | // https://github.com/facebook/react/issues/1698 |
| 2935 | // Then we restore state of any controlled component. |
| 2936 | isBatching = false; |
| 2937 | var controlledComponentsHavePendingUpdates = needsStateRestore(); |
| 2938 | if (controlledComponentsHavePendingUpdates) { |
| 2939 | // If a controlled event was fired, we may need to restore the state of |
| 2940 | // the DOM node back to the controlled value. This is necessary when React |
| 2941 | // bails out of the update without touching the DOM. |
| 2942 | _flushInteractiveUpdates(); |
| 2943 | restoreStateIfNeeded(); |
| 2944 | } |
| 2945 | } |
| 2946 | } |
| 2947 | |
| 2948 | function interactiveUpdates(fn, a, b) { |
| 2949 | return _interactiveUpdates(fn, a, b); |
no test coverage detected