mirror of
https://github.com/facebook/react.git
synced 2026-02-24 20:53:03 +00:00
There's a weird quirk leftover from the old Stack (pre-Fiber) implementation where the initial mount of a leagcy (ReactDOM.render) root is flushed synchronously even inside `batchedUpdates`. The original workaround for this was an internal method called `unbatchedUpdates`. We've since added another API that works almost the same way, `flushSync`. The only difference is that `unbatchedUpdates` would not cause other pending updates to flush too, only the newly mounted root. `flushSync` flushes all pending sync work across all roots. This was to preserve the exact behavior of the Stack implementation. But since it's close enough, let's just use `flushSync`. It's unlikely anyone's app accidentally relies on this subtle difference, and the legacy API is deprecated in 18, anyway.