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

Error passing route name as parameter to navigation function, react-navigation 6

$
0
0

After updating to react-navigation 6x when passing the navigation function it reports this error:

enter image description here

According to the documentation I need to type my createStackNavigation, I did, but it goes with an error. My route file:

import React from 'react';import { createStackNavigator } from '@react-navigation/stack';import { Home } from '../screens/Home';import { NewCall } from '../screens/NewCall';export type RootStackParamList = {  Home: undefined;  NewCall: undefined;};const { Navigator, Screen } = createStackNavigator<RootStackParamList>();export function AppStackRoutes() {  return (<Navigator      initialRouteName="Home"      screenOptions={{        headerShown: false,      }}><Screen        name="Home"        component={Home}      /><Screen        name="NewCall"        component={NewCall}      /></Navigator>  )}

my navigation function:

const navigation = useNavigation();function handleNavigation() { navigation.navigate('NewCall');}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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