pmndrs / react-three-next

React Three Fiber, Threejs, Nextjs starter
https://react-three-next.vercel.app/
MIT License
2.52k stars 342 forks source link

Static site builds fail when running with client-side error TypeError: Cannot redefine property: _currentRenderer #98

Closed ivyroot closed 2 years ago

ivyroot commented 2 years ago

I took the following steps to build the example site and export it as a static site:

yarn create r3f-app next my-app cd my-app npm run-script dev ==> site works fine when browsing to localhost:3000 npm run-script export then http-server out (after first npm installing http-server globally)

When viewing the page there is a client-side error:

"Application error: a client-side exception has occurred (see the browser console for more information)."

Console output looks like this:

framework-3583eef75b58b7b2.js:1 TypeError: Cannot redefine property: _currentRenderer
    at Function.defineProperties (<anonymous>)
maxsilvaweb commented 2 years ago

Yes I also have this problem. When deploying to Vercel it also shows this error message.

Application error: a client-side exception has occurred (see the browser console for more information).

Did you get anywhere with this @ivyroot?

ivyroot commented 2 years ago

@maxsilvauk i was not able to resolve this issue in my project. Instead I made a fresh template made with Create React App, added a Canvas element in there as per the R3F docs here: https://docs.pmnd.rs/react-three-fiber/getting-started/your-first-scene#setting-up-the-canvas, then copied the code I wrote into that. Built fine that way.

maxsilvaweb commented 2 years ago

@ivyroot - I would use this instead https://github.com/pmndrs/react-three-next

skrichten commented 2 years ago

+1 ... Same issue for me.

skrichten commented 2 years ago

Downgrading r3f from ^8.8.4 to 8.7.2 fixed this for me

CodyJasonBennett commented 2 years ago

Try updating R3F to latest or upgrading your lockfile and doing a clean install. This is related to https://github.com/pmndrs/react-three-fiber/issues/2533 which is fixed in newer patches.

RenaudRohlinger commented 2 years ago

This issue should be fixed with the latest r3f version thanks @CodyJasonBennett