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

How do I consolidate type annotations for component props while type checking screen components using NavigationStackScreenComponent type annotation?

$
0
0

Given below is the example available in React Navigation documentation for Version 4.x

import { NavigationStackScreenComponent } from 'react-navigation-stack';

type Params = { userId: string };

type ScreenProps = { language: string };

const ProfileScreen: NavigationStackScreenComponent<
  Params,
  ScreenProps
> = props => {
  // ...
};

ProfileScreen.navigationOptions = {
  headerTitle: 'Profile',
};

I am still a noob in the typescript world but trying to adapt it to my React Native Projects. The problem I am having is that NavigationStackScreenComponent generic accepts types for navigation params and screenProps but there is no way (maybe there is but I couldn't find it!) for me to add type annotations for component props.


Viewing all articles
Browse latest Browse all 6208

Trending Articles



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