我对React Navigation的抽屉导航器有问题。我有一个用户验证电子邮件的屏幕。如果已验证,它将导航到抽屉导航中的HomeScreen
这是我的代码:
navigateToHomeScreen () {
const actions = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({routeName: 'NavigationDrawer'})
]
})
this.props.navigation.dispatch(actions)
this.props.dismissModal()
}
verification.js
const NavigationDrawer = DrawerNavigator({
HomeScreen: {
screen: HomeScreen,
navigationOptions: {
drawerLabel: 'Home'
}
}
}, {
initialRouteName: 'HomeScreen',
contentComponent: props => <DrawerContent {...props} />
})
export default NavigationDrawer
NavigationDrawer.js
const PrimaryNav = StackNavigator(
{
RegisterScreen: {screen: RegisterScreen},
ConfirmVerificationCodeScreen: {screen:ConfirmVerificationCodeScreen},
LoginScreen: {screen: LoginScreen},
NavigationDrawer: {screen: NavigationDrawer},
HomeScreen: {screen: HomeScreen}
},
{
initialRouteName: 'LoginScreen',
headerMode: 'none'
})
export default PrimaryNav
AppNavigation.js
,当我在验证内导航到主屏幕时,它会引发错误
TypeError: undefined is not an object (evaluating 'route.routeName')
请帮忙。我已经仔细检查了样板,这完全很好。我导入了文件需要的所有内容
我发现了如何通过添加此方法来解决
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
to the drawer, configs fixed the issue for me.
在这里查看:https://github.com/reaect-community/reaect--导航/问题/3148#ISSUECOMMENT-35277884
这是反应 - 游动的错误。由于现在已修复,因此您可以通过更新您的React-Navigation来解决它。
https://github.com/reaect-navigation/reaeact-navigation/issues/3148
检查此链接。