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

How to read typescript error in order to understand what type should be used?

$
0
0

I don't understand how to handle typescript error like this.
I am using react-navigation and tried to make custom header.
From documentation there are list of parameters that this component get but I don't know how to type check it.

interface CustomHeaderProps {  navigation: any;  route: any;  options: any;  back: any;}const CustomHeader: FC<CustomHeaderProps> = ({  navigation,  route,  options,  back,}) => {...

I set that header in navigator:

<HomeStack.Navigator      screenOptions={{        header: props => <CustomHeader {...props} />,      }}>

And here I get error:

(alias) const CustomHeader: React.FCimport CustomHeaderType '{ back?: { title: string; } | undefined; options: NativeStackNavigationOptions; route: Route<string, object |undefined>; navigation: NativeStackNavigationProp<ParamListBase,string, undefined>; }' is not assignable to type 'CustomHeaderProps'.Property 'back' is optional in type '{ back?: { title: string; } | undefined; options: NativeStackNavigationOptions; route:Route<string, object | undefined>; navigation:NativeStackNavigationProp<ParamListBase, string, undefined>; }' butrequired in type 'CustomHeaderProps'.

Can somebody help me how to understand this kind off errors and how to set type.


Viewing all articles
Browse latest Browse all 6287

Trending Articles