我在我的react本机应用程序中使用React Navigation,并且我有一条简单的路线,HomeScreen
和QScreen
应该可以访问抽屉,但是SplashScreen
和LoginScreen
不!
我该怎么做?
此代码无法正常工作,并在HomeScreen
(在SplashScreen
中调用)的读取参数中引发错误:
const MainStack = createStackNavigator({
HomeScreen: { screen: HomePage, navigationOptions: noHeadersNavigationOptions },
QScreen: { screen: QPage, navigationOptions: noHeadersNavigationOptions },
}, {
initialRouteName: 'HomeScreen',
});
const DrawerStack = createDrawerNavigator({
MainStack ,
}, {
initialRouteName: 'MainStack',
});
const Router = createStackNavigator({
SplashScreen: { screen: SplashScreenPage },
LoginScreen: { screen: LoginPage },
HomeScreen: DrawerStack,
}, {
initialRouteName: 'SplashScreen',
}
);
export default createAppContainer(Router);
在SplashScreenPage
中:
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'HomeScreen', params: params })],
});
this.props.navigation.dispatch(resetAction);
答案 0 :(得分:0)
使用这种导航结构,我获得了类似的结果:
这是一个有效的示例: