Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应导航5,未定义的参数_Javascript_Reactjs_React Native_Expo_React Navigation - Fatal编程技术网

Javascript 反应导航5,未定义的参数

Javascript 反应导航5,未定义的参数,javascript,reactjs,react-native,expo,react-navigation,Javascript,Reactjs,React Native,Expo,React Navigation,我有一个RootNavigator(堆栈),其中有一个TabNavigator。在TabNavigator中有多个屏幕,包括堆栈导航器,其中有一个名为“Profile”的屏幕 我试图做的只是从RootNavigator的屏幕向Profile发送一个param 根导航器屏幕 // Navigate to the profile screen navigation.navigate("Profile", { isUploadingContent: true, }); //

我有一个RootNavigator(堆栈),其中有一个TabNavigator。在TabNavigator中有多个屏幕,包括堆栈导航器,其中有一个名为“Profile”的屏幕

我试图做的只是从RootNavigator的屏幕向Profile发送一个param

根导航器屏幕

// Navigate to the profile screen
navigation.navigate("Profile", {
  isUploadingContent: true,
});
// Navigate to the profile screen (nested navigator)   

navigation.navigate("TabNavigator", {
  screen: "Profile",
  params: {
    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
navigation.navigate("Profile", {
  isUploadingContent: true,
});
// Navigate to the profile screen (nested navigator)   

navigation.navigate("TabNavigator", {
  screen: "Profile",
  params: {
    isUploadingContent: true,
  },
});

你知道这里出了什么问题吗?谢谢。

好的,我找到了解决办法。就像

navigation.navigate("TabNavigator", {
  screen: "Profile",
  params: {
    isUploadingContent: true,
  },
});
但是,在最底层,我有一个名为“Profile”的堆栈导航器,其中还有另一个屏幕名为“Profile”,我不得不用“Profile”替换“TabNavigator”,并且工作正常

navigation.navigate("Profile", {
  screen: "Profile",
  params: {
    isUploadingContent: true,
  },
});

谢谢你,完美使用
根导航