React Native android - `View` ha

作者: 考特林 | 来源:发表于2017-07-05 13:22 被阅读0次

    直接用react-native init demo 新建完一个项目,再用react-native run-android启动项目。
    报错:

    'View' has no propType for native prop 'RCTView.nativeID' of native type 'String' 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.verifyPropTypes

    原因是项目的react native 的版本跟android项目里面使用的react native 版本不一致导致的。

    解决:

    1. cd 到项目目录 vim package.json 查看 项目使用的 react native 版本 如
    "dependencies": {
                    "react": "16.0.0-alpha.12",
                    "react-native": "0.45.1"
    }
    
    1. 再打开android项目中的build.gradle,将
      compile "com.facebook.react:react-native:+"
      修改成
      compile "com.facebook.react:react-native:0.45.1"
      与项目版本保持一致。

    2. 关闭React Packager 命令窗,重新运行react-native run-android 命令。

    以上,完毕。

    相关文章

      网友评论

        本文标题:React Native android - `View` ha

        本文链接:https://www.haomeiwen.com/subject/yxqqhxtx.html