0

I’m running into a strange issue with react-three-fiber that only shows up in development, but not after deploying to Vercel.

Here’s my setup:

<Canvas gl={{ antialias: true }} camera={{ position: [0, 0, 10], fov: 25, near: 1, far: 100 }}>
  <mesh ref={globeRef}>
    <sphereGeometry args={[2, 18, 18]} />
    <meshStandardMaterial transparent opacity={0.9} />
    <Edges color="gray" lineWidth={0.5} threshold={0.1} />
    {countries && <primitive object={countries} />}
  </mesh>

  <Abc globeRef={globeRef} />
  <OrbitControls enableZoom={false} enableDamping />
</Canvas>

I pass the mesh ref into another component and use it inside useFrame:

function Abc({ globeRef }) {
  useFrame((state, delta) => {
    if (globeRef) {
      console.log("Hello:", delta)
      console.log(globeRef)
    }
  })
  return null
}

Even though I’m just logging the ref, I get this error in development:

Uncaught TypeError: Cannot convert undefined or null to object
at three.core.js:14737

What’s confusing is:

  • It only happens in development
  • It never happens in production
  • If I remove these two lines, the error goes away in dev:
<Edges color="gray" lineWidth={0.5} threshold={0.1} />
{countries && <primitive object={countries} />}

I don’t understand why these components affect the ref or why this issue only exists in development.Here is the component where the error originates: https://github.com/sakshamwithweb/uConnect/blob/main/components/Globe.js

In DevTools, the error ultimately points to this line in Three.js:

delete data.metadata;

However, the first line from my own code that appears in the stack trace is:

console.log(globeRef)

2
  • 1
    Why your first and two last code fences are marked as JavaScript? These codes are not JavaScript. Commented 4 hours ago
  • 1
    Now, three.core.js:14737 is not informative. To report an issue, you should better execute your code under the debugger or review the exception stack, find the line in your code where the exception was thrown or propagated to, mark this line with some comment and refer to that comment in the body of your question. Commented 4 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.