pmndrs / use-cannon

👋💣 physics based hooks for @react-three/fiber
https://cannon.pmnd.rs
2.73k stars 153 forks source link

[Examples] ref type mismatch #376

Closed harris-jacob closed 2 years ago

harris-jacob commented 2 years ago

Minimal reproduce: https://codesandbox.io/s/recursing-feather-efyxq0?file=/src/Index.tsx

Hello, I was trying to get the hello world example in the README up and running in a basic typescript setup and seem to be getting some type mismatches on the ref object returned by the hooks. react-three-fiber elements seem to expect refs to the derived class (e.g. RefObject<Mesh>) and not to the base Object3D.

As far as I can tell, I have the correct dependency versions of everything. I am able to get around this issue by using the fwdRef arg and passing an explicit reference to the Three JS element I am using, but (assuming this is an actual issue and not just an issue with my setup), I was wondering how hard it would be for the hooks to take a generic that extends Object3D rather than always returning the base RefObject<Object3D>

Great work by the way, loving the library so far :)

harris-jacob commented 2 years ago

Addressed in #377