react-native - React Native UWP (vnext) - 导入 react-navigation-stack 会导致错误:“无法读取未定义的属性‘方向’”
问题描述
我目前正在开发一个简单的“hello-world”类型项目,它在 Android 和 UWP 上都可以正常工作,直到我使用import { createStackNavigator } from 'react-navigation-stack';
. App.js
该应用程序仍然可以在 Android 中运行,但在 UWP 中,应用程序屏幕只是白色的,并且 chrome 调试器给了我以下错误消息:
...\ReactNative\MyApp_ReactNative\node_modules\react-native-windows\Libraries\Core\ExceptionsManager.js:86 Cannot read property 'Direction' of undefined
...\MyApp_ReactNative\node_modules\react-native-windows\Libraries\Core\ExceptionsManager.js:86 Module AppRegistry is not a registered callable module (calling runApplication)
几天来我一直在努力解决这个问题,我根本找不到任何解决方案。我怀疑 react-native-windows 的 vnext 版本不支持 react-navigation-stack,或者我可能需要使用以前版本的 react-navigation-stack 才能与 UWP 一起使用。
我对 React 和 React Native 完全陌生,所以请保持解释的简单一些。要重现,请按照本指南https://github.com/microsoft/react-native-windows/blob/master/vnext/docs/GettingStarted.md,然后是https://facebook.github.io/的第一部分react-native/docs/navigation直到你到达关于 react-navigation-stack 的部分。如果我可以提供更多信息,那将很有帮助,我很乐意提供。
这是我的package.json
文件:
{
"name": "MyApp_ReactNative",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.8.6",
"react-native": "^0.60.0",
"react-native-gesture-handler": "^1.5.1",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "1.0.0-alpha.23",
"react-native-windows": "0.60.0-vnext.74",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"rnpm-plugin-windows": "^0.3.8"
},
"devDependencies": {
"@babel/core": "^7.7.2",
"@babel/runtime": "^7.7.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
解决方案
推荐阅读
- r - 布朗运动的桥采样
- r - 如何在使用 ggplot2 的两行中使用表达式时添加三行 y 轴文本?
- performance - AVX中绝对值的浮点比较
- java - 您将如何向命令添加可选参数?
- javascript - React Custom Hook 使返回函数在事件上可执行
- c++ - 我可以更改通用可变参数 lambda 的模板参数推导顺序吗?
- rust - 如何将特征对象的 Vec 转换为树结构?
- python - 如何使 elif 语句和 ValueError 重复功能除外?
- kotlin - 如何使用 Kotlin DSL 安装 JUnit5?
- jupyter-notebook - 保存笔记本小部件状态并在重新加载笔记本后允许小部件交互