【问题标题】:React Native: No propType for native prop RCTView.maxHeightReact Native:本机道具 RCTView.maxHeight 没有 propType
【发布时间】:2016-11-25 23:27:03
【问题描述】:

升级到 RN 0.30 后,即使在构建最简单的app 时,我也开始看到如下所示的错误:

react-native init AwesomeProject
react-native run-ios
  • 最奇怪的是组件BlurViewVibrancyViewRNSearchBar 包含在警告消息中,尽管项目没有使用它们。
  • 重新编译/清理项目并不能解决问题。

控制台和错误:

2016-07-22 08:48:02.985 [warn][tid:main][RCTEventEmitter.m:52] Sending `websocketFailed` with no listeners registered.
2016-07-22 08:48:03.031 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "BlurView" does not exist
2016-07-22 08:48:03.032 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "VibrancyView" does not exist
2016-07-22 08:48:03.033 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RNSearchBar" does not exist
2016-07-22 08:48:03.040 [error][tid:com.facebook.react.JavaScript] `Constructor` has no propType for native prop `RCTView.maxHeight` of native type `CGFloat`
If you haven't changed this prop yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
2016-07-22 08:48:03.043 [fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: `Constructor` has no propType for native prop `RCTView.maxHeight` of native type `CGFloat`
If you haven't changed this prop yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
2016-07-22 08:48:03.102 [error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module.
2016-07-22 08:48:03.104 [fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: Module AppRegistry is not a registered callable module.

【问题讨论】:

  • 提示你的js和native代码不同步。你试过“react-native upgrade”吗?
  • 尝试这个没有帮助,我所有的包都是最新的,我正在使用 React Native v.0.30

标签: javascript ios reactjs npm react-native


【解决方案1】:

这个错误的原因是在我更新到0.30 之后,另一个 React 打包器实例(仍在 0.28 上)在后台运行。

重启 React packager 解决了这个问题。

【讨论】:

  • 因为打包程序可以在后台进程中运行,所以不要忘记检查lsof -n -i4TCP:8081
  • 如何“重启 React packager”?
  • @Negin Basiri 在 OSX 上它通常会打开一个单独的终端窗口,只需关闭它并再次运行您的 xcode 项目。
  • 在我的情况下,它是打包程序运行到不同的项目中。谢谢你的提示!
【解决方案2】:

我通过 react-native start 重新启动了 react native,它解决了我的问题。

【讨论】:

    【解决方案3】:

    我收到了同样的错误消息,尽管在我的情况下它是由依赖项之间的不兼容引起的。

    我解决它的方法是:

    1. 使用create-react-native-app foo 创建一个新项目。这应该会安装兼容的依赖项。
    2. 打开项目的 package.json 并更新依赖项的版本以匹配 foo 的 package.json 中的版本。
    3. 检查 expo 版本是否与文件 app.json 中的 sdkVersion 匹配,并在必要时进行更新。
    4. 删除node_modules并重新安装所有包。

    希望对你有帮助!

    【讨论】:

    • 哇,这太棒了。这是唯一对我有用的解决方案......不知道否则我会如何追踪它。谢谢!
    【解决方案4】:

    在我的情况下 react-server 和 react-project 不匹配。我使用错误的 Node 服务器运行了错误的项目。

    【讨论】:

      【解决方案5】:

      上述方法对我没有任何帮助,但 yarn cache clean 成功了。

      【讨论】:

      • react-native start --reset-cachenpm start -- --reset-cache
      猜你喜欢
      • 2023-03-15
      • 2016-10-11
      • 2019-03-24
      • 1970-01-01
      • 2018-06-03
      • 2016-11-07
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多