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

Annotating useNavigation type when it is used in a generic component

$
0
0

TLDR:Is it possible to annotate the useNavigation hook in a generic component?

If I create a <BackButton /> component that uses the useNavigation() hook is there a way to have it correctly type the hook when it is used in multiple screens?

The docs recommend typing this as:

const navigation = useNavigation<XScreenNavigationProp>();

However, this only works for when using useNavigation in a specific screen. How does one annotate the hook for more than one screen?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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