Home > Software engineering >  Cannot read properties of undefined (reading 'current')
Cannot read properties of undefined (reading 'current')

Time:07-09

I run into a three.js problem where I use .current from the useRef hook but I get an error. my text editor doesn't show the error but only the host shows it.enter image description here

Here is where I got the code: https://codesandbox.io/s/github/Rishit-5/stars-background-3d/tree/main/?file=/src/App.js

Thank you!

CodePudding user response:

Often these runtime errors are fixed by restarting your development server. Despite hot reload, some changes need the server to be restarted for example environment variables.

CodePudding user response:

in line 10 useFrame((state, delta, ref) => { try to remove the ref parameter. it should look like this useFrame((state, delta) => {

in function Stars(props) ref is defined as a constant.

  • Related