Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

how to declare the type in my functional component?

$
0
0

I wanted to declare the type in my component this way, I already saw that this is possible using classes, but how could I do it using functional components? Without having to export the interface? I have already researched a lot and found nothing about it.

const Elem1 = forwardRef((props : any, ref : { open()? : void }) => {   useImperativeHandle(ref, () => ({       open: () => console.log('opened')   }))   ....})const Elem2 = () => {    const elem1Ref = useRef<Elem1>()    elem1Ref?.current?.open()    ....}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>