I'm not using typescript in my reactjs project, but I still want to document my components with JSDocs.
The problem where is that I have a functional component with React.forwardRef
and I want to create a JSDoc to the ref because I'm using useImperativeHandle
and passing different values to the ref.
It's possible to document the ref
using JSDoc to display the methods and properties that I pass in useImperativeHandle
? If yes, how?
Where is an example of what I want
In a component I use React.fowardRef
with useImperativeHandle
export const Foo = React.fowardRef((props, ref) => {
useImperativeHandle(ref, () => ({
myMethod,
// other methods and properties
}))
return <div>{/* ... */}</div>
}
And when using the ref
for that component with fooRef.current
, I want to see myMethod
or the other properties when I type .
or press Ctrl
+ Space
.