(fn: (() => R) | void)
| 1813 | declare function flushSyncFromReconciler<R>(fn: () => R): R; |
| 1814 | declare function flushSyncFromReconciler(void): void; |
| 1815 | export function flushSyncFromReconciler<R>(fn: (() => R) | void): R | void { |
| 1816 | // In legacy mode, we flush pending passive effects at the beginning of the |
| 1817 | // next event, not at the end of the previous one. |
| 1818 | if ( |
| 1819 | pendingEffectsStatus !== NO_PENDING_EFFECTS && |
| 1820 | !disableLegacyMode && |
| 1821 | pendingEffectsRoot.tag === LegacyRoot && |
| 1822 | (executionContext & (RenderContext | CommitContext)) === NoContext |
| 1823 | ) { |
| 1824 | flushPendingEffects(); |
| 1825 | } |
| 1826 | |
| 1827 | const prevExecutionContext = executionContext; |
| 1828 | executionContext |= BatchedContext; |
| 1829 | |
| 1830 | const prevTransition = ReactSharedInternals.T; |
| 1831 | const previousPriority = getCurrentUpdatePriority(); |
| 1832 | |
| 1833 | try { |
| 1834 | setCurrentUpdatePriority(DiscreteEventPriority); |
| 1835 | ReactSharedInternals.T = null; |
| 1836 | if (fn) { |
| 1837 | return fn(); |
| 1838 | } else { |
| 1839 | return undefined; |
| 1840 | } |
| 1841 | } finally { |
| 1842 | setCurrentUpdatePriority(previousPriority); |
| 1843 | ReactSharedInternals.T = prevTransition; |
| 1844 | |
| 1845 | executionContext = prevExecutionContext; |
| 1846 | // Flush the immediate callbacks that were scheduled during this batch. |
| 1847 | // Note that this will happen even if batchedUpdates is higher up |
| 1848 | // the stack. |
| 1849 | if ((executionContext & (RenderContext | CommitContext)) === NoContext) { |
| 1850 | flushSyncWorkOnAllRoots(); |
| 1851 | } |
| 1852 | } |
| 1853 | } |
| 1854 | |
| 1855 | // If called outside of a render or commit will flush all sync work on all roots |
| 1856 | // Returns whether the the call was during a render or not |
nothing calls this directly
no test coverage detected