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

How to create a new generic object type that uses react-navigation's generics?

$
0
0

In my React Native project I have multiple screens, every screen I have to import these types and set is as props type in my screen over and over again.

import { RouteProp } from '@react-navigation/native'import { StackNavigationProp } from '@react-navigation/stack'import { NavigatorParameters } from '../references/types/navigators'type PropsType = {  navigation: StackNavigationProp<NavigatorParameters, 'ChangeData'>,  route: RouteProp<NavigatorParameters, 'ChangeData'>}function ChangeData({ navigation, route }: PropsType) {

Can it be more be simplified into like this? So from that I can only import one type only

import ScreenPropsPatternType from '../references/types/screen-props-pattern'function ChangeData({ navigation, route }: ScreenPropsPatternType<'ChangeData'>) {

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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