Error loading THREE libs for vanilla app created using 'create-react-app'
See original GitHub issueDescribe the bug
If you create a brand new React app using ‘create-react-app’ and try and use Reagraph, you get the following error in browser console:
camera-controls.module.js:922 Uncaught TypeError: THREE.Vector3 is not a constructor
at CameraControls.install (camera-controls.module.js:922:1)
at index.js:934:1
at index.js:2:1
at ./node_modules/reagraph/dist/index.js (index.js:5:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at ./src/App.tsx (bundle.js:18:66)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
It seems as if the camera-controls doesn’t have a loaded Three library and THREE.Vector3 etc is undefined.
Steps to Reproduce the Bug or Issue
- Follow steps to create a react app using https://github.com/facebook/create-react-app. Command I used was:
npx create-react-app graph-test --template typescript
- Install Reagraph
npm i reagraph --save
- Copy over basic example of Reagraph to
App.tsx
. Here is my App.tsx:
import React from 'react';
import './App.css';
import {GraphCanvas} from "reagraph";
function App() {
return (
<GraphCanvas
nodes={[
{
id: '1',
label: '1'
},
{
id: '2',
label: '2'
}
]}
edges={[
{
id: '1->2',
source: 'n-1',
target: 'n-2',
label: 'Edge 1-2'
}
]}
/>
);
}
export default App;
- Run the app using
npm start
(oryarn start
)
Expected behavior
As a user I would expect to see the example Reagraph graph but I get an error in the browser dev console and no graph
Screenshots or Videos
Platform
- Reagraph Version: 4.1.0
- OS: Windows 10 (also tested on MacOS 12.1)
- Browser: Brave (latest)
- NodeJS version: 16.14.2
Your Example Website or App
No response
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Error when using new 'react-jsx' TypeScript transform #10144
Describe the bug start a vanilla project using the typescript template open any file. you'll see an error like this this: try to...
Read more >Create a New React App
This page describes a few popular React toolchains which help with tasks like: Scaling to many files and components. Using third-party libraries from...
Read more >reactjs - Error while creating new React app ("You are running ...
Solution 3: Run this command · npm uninstall -g create-react-app · npm cache clean --force · npm cache verify · npx create-react-app my-app....
Read more >Vite 3.0 vs. Create React App: Comparison and migration guide
Learn how to build React applications with Vite and how to migrate from Create React App to Vite. Compare the core concepts of...
Read more >How to get "create-react-app" to work with your API - Fullstack.io
Update (8/25/2016): react-scripts version 0.2.3 was released, adding a proxy feature for the Webpack development server to address CORS issues ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi I am also experiencing this issue as described in the original post, using create react app. Is there still a fix in the works?
Working with the following reagraph - 4.7.0 react - 18.2.0 node - 18.11.0 Mac OS Chrome
Same here, and trying with next.js instead of CRA, I get
Error: Must use import to load ES Module: /mnt/c/next-react-graph/node_modules/d3-force-3d/src/index.js require() of ES modules is not supported.
Does anyone know a way to get Reagraph working? (Hopefully without Vite!) Update: Works with Neutrino!