Search code examples
mobxreact-three-fiber

How to connect react-three-fiber to mobx


How to hook up react-three-fiber to mobx?

I have this component. How do I hook it up?

export default function Player(props) {
    const mesh = useRef()

    useFrame((a) => {

    });

    return (
        <mesh>
            <boxBufferGeometry args={[1, 1, 1]} />
            <meshStandardMaterial color={'orange'} />
        </mesh>
    )
}

Solution

  • Have you tried wrapping it with observer? If that doesn't work, you can use a local state and set it through a reaction callback.