我有一个TabNavigator,里面有一个RootNavigator(堆栈)。在TabNavigator中,有多个屏幕,包括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,
},
});
对这里出什么问题有任何想法吗?谢谢。
好的,我找到了解决方案。它就像是
navigation.navigate("TabNavigator", {
screen: "Profile",
params: {
isUploadingContent: true,
},
});
但是,就像在最低级别中一样,我有一个名为“ Profile”的堆栈导航器,其中还有其他相同的屏幕,我不得不将“ TabNavigator”替换为“ Profile”,并且工作正常。
navigation.navigate("Profile", {
screen: "Profile",
params: {
isUploadingContent: true,
},
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句