【发布时间】:2020-07-03 01:29:33
【问题描述】:
我有一个 RootNavigator(堆栈),里面有一个 TabNavigator。在 TabNavigator 中有多个 Screens,包括一个 Stack Navigator,其中有一个名为“Profile”的屏幕。
我想要做的只是将一个参数从 RootNavigator 的屏幕发送到 Profile。
根导航器的屏幕
// Navigate to the profile screen
navigation.navigate("Profile", {
isUploadingContent: true,
});
它可以正确导航到屏幕,但是当我获得路由参数时,它们是未定义的。
Profile.js
useEffect(() => {
// Check if content is uploading...
if (props.route.params.isUploadingContent) {
toastRef.current.show(
"Your photo will be available in a few seconds",
3500
);
}
}, []);
我也尝试如下发送参数,但得到相同的结果。
根导航器的屏幕
// Navigate to the profile screen (nested navigator)
navigation.navigate("TabNavigator", {
screen: "Profile",
params: {
isUploadingContent: true,
},
});
关于这里出了什么问题的任何想法?谢谢。
【问题讨论】:
标签: javascript reactjs react-native expo react-navigation