refactor(other): use react 18 concurrent rendering system#2993
Open
bc-maxy wants to merge 10 commits into
Open
refactor(other): use react 18 concurrent rendering system#2993bc-maxy wants to merge 10 commits into
bc-maxy wants to merge 10 commits into
Conversation
This reverts commit 3f34872.
Contributor
Author
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a141589. Configure here.
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.
What/Why?
Enabling concurrency in checkout-js: https://react.dev/blog/2022/03/29/react-v18#what-is-concurrent-react
React 19 doubles down on concurrency concepts with Actions and React is heading in a direction of making non-concurrent rendering legacy, so we will need to update our repo eventually.
This PR introduces concurrent rendering.
I had to add
flushSync(() => setCheckoutState(newCheckoutState))which is a workaround. From my understanding it's the Checkout SDK that owns which step is complete (viagetCheckoutStepStatuses). At the same time we also haveactiveStepTypein its own useState.flushSynchack just forces synchronous re-render to keep those two in sync. We need to properly fix this by eliminatingactiveStepTypelocal state if possible..Breaking Change: invalid containerId now throws instead of silently failing
renderCheckoutandrenderOrderConfirmationpreviously called ReactDOM.render(..., null) when the container element wasn't found, which only logged a warning. With the React 18 migration to createRoot, both functions now throw an explicit error:#<id>#<id>Action required: Ensure the container element exists in the DOM before calling either function. Any code that relied on silent failure with an invalid containerId (e.g. during SSR or conditional mounting) must now guard the call explicitly.
Rollout/Rollback
Revert the PR.
Testing
No new functionality, so our tests should catch any discrepancies. However, see breaking change description above - CI tests are added to highlight this behavior.
Note
Medium Risk
Updates core mount/render paths and checkout state subscription behavior to accommodate React 18 concurrent rendering, which can change timing and surface new runtime errors (e.g., missing container IDs). Test updates reduce flakiness but the rendering and state-sync changes affect critical checkout flows.
Overview
Migrates the app entrypoints to React 18 concurrent rendering by replacing legacy
ReactDOM.renderwithcreateRoot().render()inrenderCheckoutandrenderOrderConfirmation, and now throws explicit errors when the targetcontainerIdis missing.Updates
CheckoutProvidersubscriptions to wrapsetCheckoutStateinflushSyncto avoid stale step/status reads under concurrent batching, and adjusts credit-card style probing helpers to usecreateRootwith deferred unmount cleanup.Refreshes several integration tests to align with React 18 timing (
actusage,waitFor/findBy...instead ofprocess.nextTick) and tweaksjest-setupto ignore a narrower set of third-party console warnings.Reviewed by Cursor Bugbot for commit a141589. Bugbot is set up for automated code reviews on this repo. Configure here.