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

React Navigation Error - TypeScript - This Expression Is Not Callable

$
0
0

I'm trying to find the best practice for this typescript issue I'm experiencing when I upgraded to React Navigation 5. The error I'm getting is

This expression is not callable.  Each member of the union type '{ <RouteName extends "Stack1Screen1" | "Home">(...args: undefined extends SampleParamList1[RouteName] ? [RouteName] | [RouteName, SampleParamList1[RouteName]] : [...]): void; <RouteName extends "Stack1Screen1" | "Home">(route: { ...; } | { ...; }): void; } | { ...; }' has signatures, but none of those signatures are compatible with each other.ts(2349)

Here is the code I'm essentially using:

import { StackScreenProps } from '@react-navigation/stack';export type SampleParamList1 = {  Stack1Screen1: undefined;  Home: undefined;};export type SampleParamList2 = {  Stack2Screen2: undefined;  Home: undefined;};type Props =  | StackScreenProps<SampleParamList1, 'Stack1Screen1'>  | StackScreenProps<SampleParamList2, 'Stack2Screen2'>;const ThisScreen: React.FC<Props> = ({ navigation, route }) => {  const navToHome = () => navigation.navigate('Home');};

Hovering over the navigation.navigate('Home') function displays the error message.Any ideas on how to solve this? Thanks! :)


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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