pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
26.98k stars 1.54k forks source link

Breaking changes in React experimental branch #3222

Closed jackpope closed 1 week ago

jackpope commented 5 months ago

React is preparing changes, including some breaking, for the next major release. There are changes to the Reconciler that break @react-three/fiber.

To repro:

sandbox: https://codesandbox.io/p/sandbox/react-three-fiber-experimental-9hqh35

To prepare for the new versions, @react-three/fiber should build against the latest changes by upgrading react-reconciler, which requires new methods since 0.27.0. See all

CodyJasonBennett commented 5 months ago

Thanks for looking out. We're aware of this and plan to upgrade our reconciler alongside React 19 with our v9 release. I can make a PR for this shortly.

lourd commented 1 week ago

You're probably already aware of this, but adding my findings in case not. When trying React v19 on my personal site with a couple R3F sketches, they fail at runtime during dev with

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')

Call Stack
$$$reconciler
node_modules/.pnpm/react-reconciler@0.27.0_react@19.0.0-rc-f994737d14-20240522/node_modules/react-reconciler/cjs/react-reconciler.development.js (498:1)
createRenderer
node_modules/.pnpm/@react-three+fiber@8.17.5_react-dom@19.0.0-rc-f994737d14-20240522_react@19.0.0-rc-f994737d14-_5tpfayefndxx6u5t5hvu2nrgoe/node_modules/@react-three/fiber/dist/events-a5fc3e51.esm.js (223:32)

And at build time with

Failed to compile.

./node_modules/.pnpm/its-fine@1.1.1_react@19.0.0-rc-f994737d14-20240522/node_modules/its-fine/dist/index.js
Attempted import error: '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' is not exported from 'react' (imported as 'React').

Import trace for requested module:
./node_modules/.pnpm/its-fine@1.1.1_react@19.0.0-rc-f994737d14-20240522/node_modules/its-fine/dist/index.js
./node_modules/.pnpm/@react-three+fiber@8.17.5_react-dom@19.0.0-rc-f994737d14-20240522_react@19.0.0-rc-f994737d14-_5tpfayefndxx6u5t5hvu2nrgoe/node_modules/@react-three/fiber/dist/react-three-fiber.esm.js

Let me know if there's any way I can help!

CodyJasonBennett commented 1 week ago

React 19 is a breaking change and requires an upgrade for libraries to support it, with renderers requiring an extensive refactor and type changes. For R3F and the rest of the pmndrs ecosystem, we can't release support to stable until React 19 itself is out, which is frozen in RC due to unintended regressions with suspense and reconciliation. You can find a v9 alpha of R3F that supports React 19 as of the last RC with a migration guide, but I would not expect any haste in the ecosystem due to the lack of a timeline for React 19 stable. If you have any feedback during testing, I'd appreciate it in #2338, where we're tracking the v9 milestone. This issue has since been resolved, and am tracking minor cleanup upstream in https://github.com/facebook/react/issues/28956.