-
安装 patch-package,这将在以后用于使更改更加持久。
-
安装 deprecated-react-native-prop-types 通过运行
npm install deprecated-react-native-prop-types
oryarn add deprecated-react-native-prop-types
-
现在必须破解node_modules。进入node_modules/react-native/index.js,从第436行开始修改:
// Deprecated Prop Types get ColorPropType(): $FlowFixMe { invariant( false, "ColorPropType has been removed from React Native. Migrate to " + "ColorPropType exported from 'deprecated-react-native-prop-types'.", ); }, get EdgeInsetsPropType(): $FlowFixMe { invariant( false, "EdgeInsetsPropType has been removed from React Native. Migrate to " + "EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.", ); }, get PointPropType(): $FlowFixMe { invariant( false, "PointPropType has been removed from React Native. Migrate to " + "PointPropType exported from 'deprecated-react-native-prop-types'.", ); }, get ViewPropTypes(): $FlowFixMe { invariant( false, "ViewPropTypes has been removed from React Native. Migrate to " + "ViewPropTypes exported from 'deprecated-react-native-prop-types'.", ); },
修改为:
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ColorPropType
},
get EdgeInsetsPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").EdgeInsetsPropType
},
get PointPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").PointPropType
},
get ViewPropTypes(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ViewPropTypes
},
- 执行npx patch-package react-native命令保存补丁。
- 在package.json文件中加入 ,"postinstall": "patch-package"
编辑
- 重新构建应用程序。
原文有很多,筛选出来为有用的
原地址:Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types' - Stack Overflow