Open kian00sh opened 2 years ago
I think this is something to be done in user-land, OrbitControls will always write OrbitControlProps
to ref
.
You can try a few things like non-null assertions or adding null:
const controlRef = useRef<OrbitControlsProps>(null!)
//
const controlRef = useRef<OrbitControlsProps | null>(null)
Almost there:
import type { OrbitControls as OrbitControlsImpl } from 'three-stdlib'
const ref = useRef<OrbitControlsImpl>(null)
<OrbitControls ref={ref} />
Thank you for contributing! We’re marking this issue as stale as a gentle reminder to revisit it and give it the attention it needs to move forward.
Any activity, like adding an update or comment, will automatically remove the stale label so it stays on our radar.
Feel free to reach out on Discord if you need support or feedback from the community. This issue will close automatically soon if there’s no further activity. Thank you for understanding and for being part of the project!
three
version: 0.135.0@react-three/fiber
version: 7.0.21@react-three/drei
version: 7.27.3node
version: 17.3.1npm
(oryarn
) version: 1.22.17Problem description:
Expected type of OrbitalControl.ref is defined as
React.Ref<OrbitControls> | undefined
whereas the actual return type of the prop isOrbitControlProps
Relevant code:
Code:
Error:
Suggested solution:
Change the type to
React.Ref<OrbitControlProps> | undefined