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

Changing interface depending on string input

$
0
0

I saw something cool within the React Navigation type.d.ts file and wondered how I could recreate some of the functionality.

It's this line I'm trying to understand

export declare type StackNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = string> = NavigationProp<ParamList, RouteName, StackNavigationState<ParamList>, StackNavigationOptions, StackNavigationEventMap> & StackActionHelpers<ParamList>;

It seems that the StackNavigationProp can be a unique prop depending on the string that it's given for example 'Welcome'.

type RootStackParamList = {  Welcome: undefined;  SignUp: undefined;  Forgot: undefined;};interface RootScreenProps {  navigation:StackNavigationProp<RootStackParamList, 'Welcome'>}

Is there anyone out there who understands this better and could write up a simple example?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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