我在使用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
当我在verification.js中导航到主屏幕时,它会抛出错误
TypeError: undefined is not an object (evaluating 'route.routeName')
请帮忙。我已经仔细检查了样板,它完全没问题。我已经导入了文件所需的所有内容
答案 0 :(得分:0)
我发现如何解决这个问题,
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
to the drawer, configs fixed the issue for me.
看这里:https://github.com/react-community/react- 导航/问题/ 3148#issuecomment-352778884
答案 1 :(得分:0)
这是反应导航的错误。 由于它现在已修复,您可以通过更新您的反应导航来解决它。
https://github.com/react-navigation/react-navigation/issues/3148
检查此链接。