React Navigation - 即使安装并链接了手势处理程序,“无法读取未定义的属性‘状态’”

Posted

技术标签:

【中文标题】React Navigation - 即使安装并链接了手势处理程序,“无法读取未定义的属性‘状态’”【英文标题】:React Navigation - "Cannot read property 'State' of undefined" even though gesture-handler is installed & linked 【发布时间】:2019-04-18 16:11:36 【问题描述】:

问题

尝试在 React Navigation 中使用堆栈导航器时,我收到错误“无法读取未定义的属性‘状态’”。 Switch 和 bottomTabNavs 运行良好。

如果有人知道如何解决这个问题,那就太棒了!

我的尝试

我已经检查以确保 react-native-gesture-handler 已正确安装和链接。

我的 Package.json:


  "name": "app",
  "version": "5.1.0",
  "private": true,
  "devDependencies": 
    "babel-jest": "23.6.0",
    "fs-extra": "^6.0.1",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.49.2",
    "react-test-renderer": "16.7.0",
    "reactotron-react-native": "^3.2.0",
    "replace-in-file": "^3.4.2"
  ,
  "scripts": 
    "android": "react-native run-android",
    "ios": "react-native run-ios --simulator=\"iPhone X\"",
    "apk": "cd android && ./gradlew assembleRelease",
    "rename": "node ./bin/rename.js",
    "start": "react-native start",
    "test": "jest"
  ,
  "jest": 
    "preset": "react-native"
  ,
  "dependencies": 
    "axios": "^0.18.0",
    "lodash": "^4.17.11",
    "react": "16.6.3",
    "react-native": "0.58.0-rc.2",
    "react-native-firebase": "^5.2.0",
    "react-native-gesture-handler": "^1.1.0",
    "react-native-rate": "^1.1.6",
    "react-native-sensitive-info": "5.2.9",
    "react-native-splash-screen": "^3.2.0",
    "react-native-status-bar-height": "^2.3.1",
    "react-native-table-component": "^1.2.0",
    "react-navigation": "^3.3.2"
  

【问题讨论】:

【参考方案1】:

问题在于,即使 react-native 链接表明包已成功链接,但 pod 文件并未安装。

要解决此问题,请按以下步骤操作:

    cd ios Pod 安装 清理ios文件夹 运行应用程序

【讨论】:

以上是关于React Navigation - 即使安装并链接了手势处理程序,“无法读取未定义的属性‘状态’”的主要内容,如果未能解决你的问题,请参考以下文章

React-navigation- dependencies (安装 NPM 导航依赖包安装时出错)

如何在堆栈导航器(react-navigation 2.X)中卸载先前安装的组件?

在 React Native 中始终显示底部选项卡导航器 React Navigation 5

react-navigation 导航路由

React Navigation 路由导航库升级 5.x

React-native 组件缓存(或防止卸载)(react-navigation)