Skip to content

[Bug][Desktop] Invalid hook call followed by material.onBuild is not a function #441

@decipher-cs

Description

@decipher-cs

Steps to reproduce

  1. pnpm create vite
  2. Select react + typescript + swc
  3. Copy the code from the introduction page verbatim
  4. Add @vitejs/plugin-basic-ssl as suggested on the development setup page
  5. Run the dev server with pnpm vite --host
  6. Open https://localhost:5173/ on browser
  7. Click Enter AR
  8. Lose

Note: works fine on mobile

Errors Encountered

First I'm hit

Image

with and then I get

Image

Code

import { Canvas } from "@react-three/fiber";
import { XR, createXRStore } from "@react-three/xr";
import { useState } from "react";

const store = createXRStore();

function App() {
  const [red, setRed] = useState(false);
  return (
    <>
      <button onClick={() => store.enterAR()}>Enter AR</button>
      <Canvas>
        <XR store={store}>
          <mesh
            pointerEventsType={{ deny: "grab" }}
            onClick={() => setRed(!red)}
            position={[0, 1, -1]}
          >
            <boxGeometry />
            <meshBasicMaterial color={red ? "red" : "blue"} />
          </mesh>
        </XR>
      </Canvas>
    </>
  );
}

export default App;
"dependencies": {
  "@react-three/fiber": "^9.1.2",
  "@react-three/xr": "^6.6.17",
  "@vitejs/plugin-basic-ssl": "^2.0.0",
  "react": "^19.1.0",
  "react-dom": "^19.1.0",
  "three": "^0.177.0"
},

System info

I'm running on a desktop browser

Brave 1.79.119 (64-bit)
Chromium: 137.0.7151.68

Now sure if it matters but I do have all the relevant webXR flags enables as you can see here

Image

Related Issue

#433

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions