【发布时间】:2023-01-30 22:02:46
【问题描述】:
使用组件https://github.com/react-native-picker/picker,我试图创建一个使用来自 API 的值的下拉列表。 我在https://alexb72.medium.com/how-to-populate-react-native-picker-dynamically-with-values-from-an-api-dbe122e85a5a 上找到了这篇文章,其目的也是如此。 然而,它一开始就抛出错误,只是通过创建 App.js:
ERROR ReferenceError: Can't find variable: React
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication).
A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication).
A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
我在 Android 模拟器中运行。 有人有工作项目吗?
【问题讨论】:
-
将新包添加到节点模块文件夹时有时会发生这种情况。尝试清理项目并再次运行它。如果这不起作用,请尝试像这样导入 React: import * as React from 'react';
-
另外,分享一些导入代码和选择器的逻辑。
标签: react-native