dillon1000/react
Commit
Browse files Replace unbatchedUpdates with flushSync (#21776)
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.
Changed paths12 files
First-parent comparisonpackages/react-devtools-shared/src/__tests__/__snapshots__/profilingCache-test.js.snap ModifiedM packages/react-dom/src/__tests__/ReactMount-test.js ModifiedM packages/react-dom/src/client/ReactDOMLegacy.js ModifiedM packages/react-noop-renderer/src/ReactNoop.js ModifiedM packages/react-noop-renderer/src/ReactNoopPersistent.js ModifiedM packages/react-noop-renderer/src/createReactNoop.js ModifiedM packages/react-reconciler/src/ReactFiberReconciler.js ModifiedM packages/react-reconciler/src/ReactFiberReconciler.new.js ModifiedM packages/react-reconciler/src/ReactFiberReconciler.old.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.new.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.old.js ModifiedM packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…