Skip to content

refactor(other): use react 18 concurrent rendering system#2993

Open
bc-maxy wants to merge 10 commits into
masterfrom
test-react18-rendering
Open

refactor(other): use react 18 concurrent rendering system#2993
bc-maxy wants to merge 10 commits into
masterfrom
test-react18-rendering

Conversation

@bc-maxy

@bc-maxy bc-maxy commented May 5, 2026

Copy link
Copy Markdown
Contributor

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 (via getCheckoutStepStatuses). At the same time we also have activeStepType in its own useState. flushSync hack just forces synchronous re-render to keep those two in sync. We need to properly fix this by eliminating activeStepType local state if possible..

Breaking Change: invalid containerId now throws instead of silently failing

renderCheckout and renderOrderConfirmation previously 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:

  • Unable to find checkout container: #<id>
  • Unable to find order confirmation container: #<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.render with createRoot().render() in renderCheckout and renderOrderConfirmation, and now throws explicit errors when the target containerId is missing.

Updates CheckoutProvider subscriptions to wrap setCheckoutState in flushSync to avoid stale step/status reads under concurrent batching, and adjusts credit-card style probing helpers to use createRoot with deferred unmount cleanup.

Refreshes several integration tests to align with React 18 timing (act usage, waitFor/findBy... instead of process.nextTick) and tweaks jest-setup to 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.

@bc-maxy bc-maxy changed the title refactor(other): use react 18 new rendering system refactor(other): use react 18 concurrent rendering system May 5, 2026
@bc-maxy bc-maxy marked this pull request as ready for review May 6, 2026 06:52
@bc-maxy bc-maxy requested review from a team as code owners May 6, 2026 06:52
Comment thread jest-setup.ts Outdated
@bc-maxy bc-maxy marked this pull request as draft May 6, 2026 07:13
@bc-maxy bc-maxy marked this pull request as ready for review May 6, 2026 23:41
@bc-maxy

bc-maxy commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant