Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes expo

  1. 安装 patch-package,这将在以后用于使更改更加持久。

  2. 安装 deprecated-react-native-prop-types 通过运行 npm install deprecated-react-native-prop-types or yarn add deprecated-react-native-prop-types

  3. 现在必须破解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
  },
  1. 执行npx patch-package react-native命令保存补丁。

  2. 在package.json文件中加入 ,"postinstall": "patch-package"

  3. 重新构建应用程序。

原文有很多,筛选出来为有用的
原地址:Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types' - Stack Overflow

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值