Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useGLTF: Using useGLTF with createPortal causes "maximum update depth" error #2381

Open
gkjohnson opened this issue Mar 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@gkjohnson
Copy link

  • three version: 169
  • @react-three/fiber version: 8.17.9
  • @react-three/drei version: 9.114
  • node version: -
  • npm (or yarn) version: -

Problem description:

When using "useGLTF" in a component that is subsequently rendered using "createPortal" the application crashes with a "maximum update depth exceeded" or freezes the page in some cases.

Relevant code:

Here's a code sandbox the reproduces the issue:

https://codesandbox.io/p/sandbox/lively-field-9dm7gv?file=%2Fsrc%2FApp.js

function PortalTest() {
  const [group, setGroup] = useState(null)
  return (
    <>
      <group ref={setGroup} />
      {group && createPortal(<Scene />, group)}
    </>
  )
}

function Scene() {
  const { gl } = useThree()
  const { scene } = useGLTF('facecap.glb', false, false)
  return <primitive object={scene} />
}

Suggested solution:

I'm not sure whether this is a drei or r3f issue.

@gkjohnson gkjohnson added the bug Something isn't working label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant