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

Type 'string' is not assignable to type'"CommodityDetails"' | Type 'StackHeaderProps' is not assignable to type '{ route: CustomRouteProp; }'

$
0
0

Hy there, here is my code, please look at it and please tell me why I'm getting this error. I'm new to react native

    type RootStackParamList = {      MandiBhaavHome: undefined;      MandiDashboard: {mandi: {name: string}};      CommodityDetails: {commodity: {name: string}};    };    type MandiDashboardRouteProp = RouteProp<RootStackParamList, 'MandiDashboard'>;    const Stack = createStackNavigator<RootStackParamList>();    const MandiBhaavStack: FC = () => {      const {t, i18n} = Language?.useContainer();      const initI18n = i18n;      return (<Stack.Navigator initialRouteName="MandiBhaavHome"><Stack.Screen            options={{problem here--> header: (props: {route: MandiDashboardRouteProp}) => (<NavHeader                  title={`${t(props.route.params.mandi.name.toLowerCase())} ${t('mandi_bhav',                  )}`}                />              ),            }}            name="MandiDashboard"            component={MandiDashboard}          /></Stack.Navigator>      );    };

header is having red underline, on hover it is saying

Type '(props: {    route: CommodityDetailsRouteProp;}) => JSX.Element' is not assignable to type '(props: StackHeaderProps) => ReactNode'.  Types of parameters 'props' and 'props' are incompatible.    Type 'StackHeaderProps' is not assignable to type '{ route: CommodityDetailsRouteProp; }'.      Types of property 'route' are incompatible.        Type 'Route<string, object | undefined>' is not assignable to type 'CommodityDetailsRouteProp'.          Type 'Route<string, object | undefined>' is not assignable to type 'Readonly<{ key: string; name: "CommodityDetails"; path?: string | undefined; }>'.            Types of property 'name' are incompatible.              Type 'string' is not assignable to type '"CommodityDetails"'.ts(2322)

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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