Trouble with production build - React is not defined #322
Unanswered
paulstraw
asked this question in
Help Wanted!
Replies: 1 comment
-
|
Hah, yeah it's definitely trying to find a global React for some reason. I was able to work around this by statically adding |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, and thanks for your work on this project. It's a huge time saver compared to integrating all of this yourself.
Everything is working as expected in dev, but I'm running into a strange issue in builds. When I try to render a
<Unity …, I getReferenceError: React is not defined. I traced this to the call in unity.ts, but I'm not sure what the actual cause is.A bit of information about my setup:
vite 2.7.2@vitejs/plugin-react 1.1.4react 17.0.2react-unity-webgl 8.7.4typescript 4.5.4Two other things that may be of note:
vendor.{hash}.js, the actual spot that's causing the error is(0,React.createElement), which looks like it's trying to find a global React?Cannot find name 'UnityInstance'. unityInstance: UnityInstance | null;, but I've worked around that by adding a.d.tsto my project withdeclare type UnityInstance = unknownThanks for your help, and please let me know if there's any additional information I can provide!
Beta Was this translation helpful? Give feedback.
All reactions