You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Navigation跨导航器跳转报错:Navigate with payload未被处理

解决跨导航容器的页面跳转错误问题

你的问题出在使用了两个独立的NavigationContainer(都设置了independent={true}),这会让BottomTab Navigator的导航上下文和外层Stack Navigator完全隔离,导致内部页面的navigation对象找不到外层Stack里的Savepost路由,从而触发"Navigate with payload was not handled by any navigator"错误。

修复步骤:

  1. 移除BottomTab外层的独立导航容器
    嵌套导航器不需要单独包裹NavigationContainer,直接保留BottomTab.Navigator即可,让它继承外层Stack的导航上下文。修改后的MainScreen代码:
const MainScreen = () => {
  return (
    <BottomTab.Navigator
      screenOptions={{
        tabBarStyle: { backgroundColor: "black" },
        headerShown: false,
        tabBarActiveTintColor: "white",
        tabBarHideOnKeyboard: true
      }}
    >
      <BottomTab.Screen
        name="NewVideo"
        component={Newpost}
      />
      // 其他路由
    </BottomTab.Navigator>
  );
};
  1. 保留外层主导航容器
    外层的NavigationContainer保持不变,它作为整个应用的根导航上下文,负责管理所有顶层路由(包括Home、Savepost等)。

完成以上修改后,NewVideo页面里的navigation.navigate('Savepost', { source: result.assets })就能正确找到外层Stack中的Savepost页面,完成带参数的跳转。

额外说明:

independent={true}仅适用于需要完全独立导航树的场景(比如弹窗内的独立导航),普通的嵌套导航不要开启该属性,否则会切断导航上下文的传递,导致跨导航器跳转失败。

内容的提问来源于stack exchange,提问作者oussamaZAAM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 19:52:45