undefined 不是对象(正在计算 route.routeName)

undefined is not an object (evaluating route.routeName)

当将 expo 从 (16.0.0) 更新到 (24.0.0) 并将导航从 (git+https://github.com/react-community/react-navigation.git) 更新到 (^1.0.0-beta.21) 版本时,发生此错误

终于找到了解决方法,它是一个未记录 DrawerNavigatorConfig:

drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'

看这里: https://github.com/react-community/react-navigation/issues/3148#issuecomment-352778884

在 react-native 包

之前从包 json 中删除 ^

它应该看起来像这样 "react-navigation": "1.0.0-beta.20"

不是 "react-navigation":“^1.0.0-beta.20”(^ 表示您允许 npm install 安装最新版本,这是问题的原因)

删除后 ^ 你必须删除你的 node_module 然后 运行 npm install 这将为你当前的项目安装正确的包

简单地说,更改为 "react-navigation": "1.0.0-beta.26" "react-navigation" : "1.0.0-beta.20"