fix: Add deprecation warning for removed flushSync API #35428
+45
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I am submitting this PR to address issue #35424 regarding the silent removal of
flushSync. As pointed out in the issue, the renaming offlushSynctoflushSyncFromReconcilerin PR #28500 was a breaking change that causedflushSyncto becomeundefinedwithout warning, breaking custom renderers like@opentui/react.To fix this usability issue, I have:
flushSyncas a deprecated stub (placeholder function) in ReactFiberReconciler.js.__DEV__).updateContainerSync()followed byflushSyncWork(), as requested in the issue.This ensures that I help existing custom renderer authors receive a helpful error message instead of failing silently with undefined errors.
Closes #35424
How did you test this change?
I added a new test file: packages/react-reconciler/src/tests/ReactReconcilerFlushSyncDeprecation-test.js to specifically verify the deprecation logic I implemented.
Verification Steps:
yarn test ReactReconcilerFlushSyncDeprecation.Reconciler.flushSyncis exported as afunction.flushSync()emits the expectedconsole.errorwarning.updateContainerSync()followed byflushSyncWork()instead."Test Output:
PASS packages/react-reconciler/src/tests/ReactReconcilerFlushSyncDeprecation-test.js
ReactReconciler flushSync deprecation
✓ warns when accessing the deprecated flushSync export (172 ms)