TypeError: react_unity_webgl__WEBPACK_IMPORTED_MODULE_1__.UnityContext is not a constructor #281
Replies: 2 comments 1 reply
-
I deleted my project and then re-created my project and then it works, Failed to parse source map from 'D:\React\your-app\node_modules\react-unity-webgl\source\services\UnityLoaderService.ts' file: Error: ENOENT: no such file or directory, open 'D:\React\your-app\node_modules\react-unity-webgl\source\services\UnityLoaderService.ts' how can I solve this? |
Beta Was this translation helpful? Give feedback.
-
Hi. Which version of the module are you using? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am trying to use react_unity_webgl on my react.js with Javascript.
I did npx create-react-app to build a react.js project.
I put copy the provided code into the app.js .
import React from "react";
import Unity, { UnityContext } from "react-unity-webgl";
const unityContext = new UnityContext({
loaderUrl: "./unityBuild/2020.1/myunityapp.loader.js",
dataUrl: "./unityBuild/2020.1/myunityapp.data",
frameworkUrl: "./unityBuild/2020.1/myunityapp.framework.js",
codeUrl: "./unityBuild/2020.1/myunityapp.wasm",
});
const App = () => {
return <Unity unityContext={unityContext} />;
};
export default App;
But I got an error
TypeError: react_unity_webgl__WEBPACK_IMPORTED_MODULE_1__.UnityContext is not a constructor
when I do console.log(typeof UnityContext ), it returns undefined
and
my terminal keep returning this error
Failed to parse source map from 'D:\React\your-app\node_modules\react-unity-webgl\source\services\UnityLoaderService.ts' file: Error: ENOENT: no such file or directory, open 'D:\React\your-app\node_modules\react-unity-webgl\source\services\UnityLoaderService.ts'
@ ./node_modules/react-unity-webgl/distribution/components/Unity.js 47:43-84
@ ./node_modules/react-unity-webgl/distribution/Exports.js 13:30-59
@ ./src/App.js 5:0-56 8:25-37 17:30-35
@ ./src/index.js 6:0-24 10:33-36
Please help me
Beta Was this translation helpful? Give feedback.
All reactions