gpt4 book ai didi

react-native - 在抽屉堆栈之间传递参数 react 导航

转载 作者:行者123 更新时间:2023-12-04 04:23:45 25 4
gpt4 key购买 nike

我的路由器设置如下

import { createAppContainer, createDrawerNavigator, createStackNavigator, createSwitchNavigator } from "react-navigation";

import Home from "./components/Home";
import Search from "./components/Search";
import Map from "./components/Map";

import Login from "./components/Login";
import ForgotPassword from "./components/ForgotPassword";

import SideMenu from "./SideMenu";

const DashboardStack = createStackNavigator(
{
Home: { screen: Home },
Search : {screen : Search}
}
);

const MapStack = createStackNavigator(
{
Map: { screen: Map },
}
);

const AuthStack = createStackNavigator(
{
Login: { screen: Login },
ForgotPassword: { screen: ForgotPassword },
}
);

export const DrawerStack = createDrawerNavigator(
{
Dashboard: { screen: DashboardStack },
Map: { screen: MapStack },
},
{
contentComponent: SideMenu,
drawerWidth: 250
}
);

export const AppNavigator = createStackNavigator(
{
Drawer: { screen: DrawerStack },
Auth: { screen: AuthStack },
},
{
// initialRouteName: "Drawer",
headerMode: 'none',
mode: 'modal',
}
);

export default createAppContainer(DrawerStack);

一切正常,只是一个小问题。当我从家里导航到搜索屏幕,然后使用参数切换到“ map ”屏幕时,这些参数没有到达“ map ”屏幕。

我当前的设置是 codepan

最佳答案

您的问题是您的MapStack和“ map ”屏幕都具有相同的名称“ map ”。

只需将MapStack路由替换为“MapStack”之类的其他东西,您就会获得参数。

看到这里:https://snack.expo.io/SyTFUPZUB

export const DrawerStack = createDrawerNavigator(
{
Dashboard: { screen: DashboardStack },
MapStack: { screen: MapStack },
},
{
contentComponent: SideMenu,
drawerWidth: 250
}
);

关于react-native - 在抽屉堆栈之间传递参数 react 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57691710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com