pmndrs / react-three-fiber

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

React 19 support - "Cannot read properties of undefined (reading 'ReactCurrentOwner')" #3398

Closed AndrewRayCode closed 21 hours ago

AndrewRayCode commented 3 days ago

I'm not sure yet, but react-three-fiber may not be compatible with React 19. Running react-three-fiber in react@19.0.0-rc-66855b96-20241106 raises an error:

hook.js:608 TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner') at $$$reconciler (react-reconciler.development.js:498:46) at createRenderer (events-321b05fb.esm.js:223:31) at [project]/node_modules/@react-three/fiber/dist/events-321b05fb.esm.js [app-client] (:3000/ecmascript) (http://localhost:3000/_next/static/chunks/node_modules_%40react-three_fiber_dist_9ff2d1._.js:1687:36)

I had to install @react-three/fiber with --force because react@19.0.0-rc... apparently does not satisfy the >=18

npm install --save three @types/three @react-three/fiber npm error Could not resolve dependency: npm error peer react@">=18.0" from @react-three/fiber@8.17.10 npm error node_modules/@react-three/fiber npm error @react-three/fiber@"*" from the root project

This is an issue because npx create-next-app apparently uses react rc19. I tried downgrading it with

npm uninstall react react-dom npm install react@18.2.0 react-dom@18.2.0

But same error in browser. Either way it looks like there might be reconciler(?) changes in React 19 that r3f does not currently support.

pooya-badiee commented 1 day ago

For me at least, It does not work with next 15 in general, I don't know if it is a problem with next 15 or react 19

iamdangavin commented 21 hours ago

It looks to be a Next 15 compatibility issue that is discussed in this thread #3222

AndrewRayCode commented 21 hours ago

closing as dupe then!