lib/accept: migrate off ReactDom.render/unmountComponentAtNode (React 19)#111663
Open
taipeicoder wants to merge 1 commit into
Open
lib/accept: migrate off ReactDom.render/unmountComponentAtNode (React 19)#111663taipeicoder wants to merge 1 commit into
taipeicoder wants to merge 1 commit into
Conversation
… 19) `ReactDom.render`, `ReactDom.hydrate`, and `unmountComponentAtNode` are removed in React 19. Move the imperative accept() confirm dialog to the `createRoot` API (`react-dom/client`), which is available in React 18 too, so this compiles unchanged on the current runtime. The dialog's onClose runs synchronously from inside its button click handler, and a root can't be unmounted synchronously while React is still processing that event, so the teardown is deferred to a microtask. Update the unit test to drive the now-async render/teardown through act(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of DOTCOM-17400
Proposed Changes
Migrate the imperative
accept()confirm-dialog helper off the React-DOM APIs removed in React 19 (ReactDom.renderandunmountComponentAtNode) to thecreateRootAPI fromreact-dom/client.createRootis already available in React 18, so this compiles and behaves the same on the current runtime — it's a forward-compatible change ahead of the React 19 bump.Because
createRoot's render and unmount are asynchronous and a root can't be unmounted synchronously while React is still processing the click that closes the dialog, the teardown is deferred to a microtask. The unit test is updated to drive the now-async render/teardown throughact().The public
accept()signature is unchanged, so its ~19 callers are unaffected.Why are these changes being made?
@wordpress/*packages bundled by Calypso are moving to React 19, where these React-DOM APIs no longer exist. Landing the forward-compatible source changes on trunk now keeps the eventual single version bump small and low-risk.Testing Instructions
yarn test-client client/lib/accept— all 4 suites pass.Pre-merge Checklist
🤖 Generated with Claude Code