react-prismazoom icon indicating copy to clipboard operation
react-prismazoom copied to clipboard

how to typify ref?

Open cheechoo28 opened this issue 2 years ago • 3 comments

In your demo I see this typing ref image What is the ComponentRef? I don't understand how I can do typing :(

cheechoo28 avatar Jun 26 '23 10:06 cheechoo28

It's a React type, it's used to make a typed reference of PrismaZoom. In a few lines below, you can see that calling methods like zoomOut is completely understood by Typescript.

sylvaindubus avatar Jun 27 '23 20:06 sylvaindubus

@sylvaindubus I have "typescript": "~5.1.3" and "react": "16.14.0" and I can't export ComponentRef from React. I can't find anything about the ComponentRef in the React documentation

cheechoo28 avatar Jun 29 '23 06:06 cheechoo28

@cheechoo28 Well, I am using react 17.0.2 and it really exists, but I couldn't find any documentation around it either. :( Anyway, it's the only way I've found to correctly type this ref including bounded methods.

sylvaindubus avatar Jul 02 '23 06:07 sylvaindubus