【发布时间】:2022-12-13 01:13:04
【问题描述】:
尝试导航时出现以下错误:
Uncaught TypeError: Cannot read properties of undefined (reading 'navigate')
这是我的主要组成部分:
const Stack = createStackNavigator<StackParamList>();
type StackParamList = {
Home: undefined;
NewTrip: undefined;
};
export default function UserStack() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="NewTrip" component={NewTripsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
这是我未能成功调用它的地方:
const TripsProfileScreen: FunctionComponent<TripsSectionProfileProps> = (
props, navigation
) => {
return (
<Container>
<IconButton
onPress={() => navigation.navigate('NewTrip')}
</IconButton>
</Container>
)
}
我究竟做错了什么?谢谢。
【问题讨论】:
标签: typescript react-native react-navigation