React Native android - `View` has no propType for native prop `RCTView.nativeID`

直接用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` has no propType for native prop `RCTView.nativeID`)