feat: support React 19.3 - #3916
Open
cades wants to merge 2 commits into
Open
Conversation
The `react`/`react-dom` peer range was capped at `<19.3`, and the cap was load-bearing: React 19.3 added a `types` field to the transition object, and `react-dom` 19.3 reads it guarded against `null` rather than `undefined`. The vendored reconciler was built from `react-reconciler` 0.33.0, which mints transitions without that field, so `undefined` passed the guard and `queueTransitionTypes` then threw on `undefined.length`. In practice that meant any component inside the R3F tree calling `useTransition()` and updating state in the surrounding DOM tree crashed with `Cannot read properties of undefined (reading 'length')`, surfaced through `onUncaughtError`. Reported in pmndrs#3915 with a standalone reproduction. Rebuilding the vendored reconciler from `react-reconciler` 0.34.0 — the release that declares `react: ^19.3.0` — fixes it. `scheduler` moves to ^0.28.0 to match what 0.34.0 depends on, so the package keeps a single scheduler instance rather than resolving two. The peer range moves to `>=19 <19.4`, keeping the existing convention of an explicit upper bound. Verified against the reproduction from pmndrs#3915, holding everything else constant and swapping only the built `dist`: upstream dist -> useTransition inside the R3F tree throws this dist -> no error upstream dist -> throws again (with scheduler already at 0.28.0) The third arm rules out the scheduler bump as the cause. React's own `startTransition` is clean in every arm, which rules out the harness. `yarn test` passes on React 19.3.0 with no snapshot changes: 15 suites, 173 passing, 1 todo, 14 snapshots — identical to the run before this change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The suite had no coverage for the case the reconciler bump fixes: a component inside the R3F tree starting a transition that updates state in a react-dom root. Everything else stayed green while that path threw, which is why the incompatibility reached a release. Checked that it actually catches the bug rather than assuming it does, by rebuilding the vendored reconciler both ways and running it against each: built from react-reconciler 0.33.0 -> fails built from react-reconciler 0.34.0 -> passes The `setTimeout(50)` is because the throw happens while the root is being scheduled rather than during the update, so the scheduled work has to run before the assertion. Suite on React 19.3.0: 16 suites, 174 passing, 1 todo, 14 snapshots unchanged. Co-Authored-By: Claude Opus 5 (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.
Fixes #3915.
What was wrong
The
react/react-dompeer range was capped at<19.3, and that cap turned out to be load-bearing rather than precautionary.React 19.3 added a
typesfield to the transition object (19.2 mints{_updatedFibers}, 19.3 mints{types, _updatedFibers}).react-dom19.3 reads it guarded againstnull, not againstundefined:and
queueTransitionTypesimmediately readstransitionTypes.length.The vendored reconciler is built from
react-reconciler0.33.0, which mints transitions with notypesfield.undefinedpasses thenull !== …guard, and the read then throws.The user-visible effect: any component inside the R3F tree calling
useTransition()and updating state that lives in the surrounding DOM tree throwsCannot read properties of undefined (reading 'length'), surfaced throughonUncaughtError— so it trips an error boundary rather than failing quietly.The change
react-reconciler0.33.0 → 0.34.0 (the release that declaresreact: ^19.3.0), which is what gets vendored bypatch-react-reconciler@types/react-reconciler0.32.3 → 0.33.0 to matchscheduler^0.27.0 → ^0.28.0, which is whatreact-reconciler0.34.0 depends on — without this the package resolves two scheduler instances with independent task queues rather than onereact/react-dom>=19 <19.3→>=19 <19.4, keeping the existing convention of an explicit upper boundreact/react-dom^19.2.0 → ^19.3.0, so local development and the test run exercise the React this targetsNo source changes — the reconciler is a build artifact of
patch-react-reconciler, so bumping the dependency is the whole fix. The one added file is a test (below).Test
The suite had no coverage for the case this fixes — a transition started inside the R3F tree updating state in a react-dom root — which is why everything stayed green while that path threw.
packages/fiber/tests/transitions.test.tsxcovers that crossing.I checked it actually catches the bug rather than assuming it does, by rebuilding the vendored reconciler both ways and running it against each:
react-reconciler0.33.0react-reconciler0.34.0The
setTimeout(50)in it is because the throw happens while the root is being scheduled rather than during the update, so the scheduled work has to run before the assertion. Happy to replace it if you have a preferred idiom for that in this suite.Verification
Using the standalone reproduction from #3915, holding everything constant and swapping only the built
dist:distReact.startTransition(control)useTransition()inside the R3F treeCannot read properties of undefined (reading 'length')scheduleralready at 0.28.0The third row is there on purpose: it rules out the scheduler bump as the thing that fixed it, leaving the rebuilt reconciler as the cause. The control column staying clean throughout rules out the harness.
yarn teston React 19.3.0 — 16 suites, 174 passing, 1 todo, 14 snapshots, no snapshot changes. Before this branch: 15 suites, 173 passing; the difference is the added test.Notes for review
minorfor the changeset, following 9.5.0 ("Support React 19.2"). Happy to change it topatchif you would rather treat it as a compatibility fix.v10, which has the identical problem.<19.4, which keeps the current approach of pinning to a known-good React minor. If you would prefer to drop the upper bound, or to widen it differently, say so and I will adjust — I did not want to change that policy in a PR that is otherwise mechanical.🤖 Generated with Claude Code