我在使用React Navigation的Drawer Navigator时遇到了问题 . 我有一个用户验证电子邮件的屏幕 . 如果经过验证,它将导航到抽屉导航中的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')
请帮忙 . 我已经仔细检查了样板,它完全没问题 . 我已导入文件所需的所有内容
2 回答
我发现如何解决这个问题,
看这里:https://github.com/react-community/react-导航/问题/ 3148#issuecomment-352778884
这是反应导航的错误 . 由于它现在已修复,您可以通过更新您的反应导航来解决它 .
https://github.com/react-navigation/react-navigation/issues/3148
检查此链接 .