How to use useRef with Typescript?
kyrregjerstad opened this issue · comments
Kyrre Gjerstad commented
I'm trying to use useRef with typescript, but I cannot seem to get the correct type for the ref. What would be the correct way to set this up?
import { ForceGraph3D } from 'react-force-graph';
const Graph = () => {
const ref = useRef<WhatGoesHere?>();
return (
<ForceGraph3D
ref={ref}
...
/>
)
}
Ian Tuomi commented
Hope this helps:
import { ForceGraphMethods } from 'react-force-graph-3d'
...
const ref = useRef<ForceGraphMethods>()