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
-
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.4
react 17.0.2
react-unity-webgl 8.7.4
typescript 4.5.4
Two 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.ts
to my project withdeclare type UnityInstance = unknown
Thanks 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