【问题标题】:How can i fix this error Invariant Violation: ViewPropTypes has been removed from React Native我该如何解决这个错误 Invariant Violation: ViewPropTypes has been removed from React Native
【发布时间】:2022-09-25 02:40:56
【问题描述】:

如何解决这个错误我正在使用expo react native ERROR Invariant Violation: ViewPropTypes 已从 React Native 中删除。迁移到从 \'deprecated-react-native-prop-types\' 导出的 ViewPropTypes。这是错误请检查我提供的代码

我的 package.json

{
  \"main\": \"node_modules/expo/AppEntry.js\",
  \"scripts\": {
    \"start\": \"expo start\",
    \"android\": \"expo start --android\",
    \"ios\": \"expo start --ios\",
    \"web\": \"expo start --web\",
    \"eject\": \"expo eject\"
  },
  \"dependencies\": {
    \"@react-native-community/masked-view\": \"0.1.10\",
    \"@react-navigation/bottom-tabs\": \"^5.11.10\",
    \"@react-navigation/compat\": \"^5.3.20\",
    \"@react-navigation/native\": \"^5.9.4\",
    \"@react-navigation/stack\": \"^5.14.4\",
    \"expo\": \"^46.0.0\",
    \"expo-av\": \"~12.0.4\",
    \"expo-linear-gradient\": \"~11.4.0\",
    \"expo-status-bar\": \"~1.4.0\",
    \"haversine\": \"^1.1.1\",
    \"react\": \"18.0.0\",
    \"react-dom\": \"18.0.0\",
    \"react-native\": \"0.69.5\",
    \"react-native-animatable\": \"^1.3.3\",
    \"react-native-flexi-radio-button\": \"^0.2.2\",
    \"react-native-fontawesome\": \"^7.0.0\",
    \"react-native-gesture-handler\": \"~2.5.0\",
    \"react-native-modal\": \"^13.0.0\",
    \"react-native-modalize\": \"^2.0.8\",
    \"react-native-progress-circle\": \"^2.1.0\",
    \"react-native-reanimated\": \"~2.9.1\",
    \"react-native-safe-area-context\": \"4.3.1\",
    \"react-native-screens\": \"~3.15.0\",
    \"react-native-snap-carousel\": \"^3.9.1\",
    \"react-native-swiper\": \"^1.6.0\",
    \"react-native-web\": \"~0.18.7\",
    \"react-navigation\": \"^4.4.4\",
    \"rn-sliding-up-panel\": \"^2.4.5\"
  },
  \"devDependencies\": {
    \"@babel/core\": \"^7.18.6\"
  },
  \"private\": true
}

我的 app.json

{
  \"expo\": {
    \"name\": \"amdy-edu\",
    \"slug\": \"amdy-edu\",
    \"version\": \"1.0.0\",
    \"orientation\": \"portrait\",
    \"icon\": \"./assets/icon.png\",
    \"splash\": {
      \"image\": \"./assets/splash.png\",
      \"resizeMode\": \"contain\",
      \"backgroundColor\": \"#ffffff\"
    },
    \"updates\": {
      \"fallbackToCacheTimeout\": 0
    },
    \"assetBundlePatterns\": [
      \"**/*\"
    ],
    \"ios\": {
      \"supportsTablet\": true
    },
    \"android\": {
      \"adaptiveIcon\": {
        \"foregroundImage\": \"./assets/adaptive-icon.png\",
        \"backgroundColor\": \"#FFFFFF\"
      }
    },
    \"web\": {
      \"favicon\": \"./assets/favicon.png\"
    }
  }
}

我的 babel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: [\'module:metro-react-native-babel-preset\'],
    plugins: [\'react-native-reanimated/plugin\'],
  };
};

    标签: javascript reactjs react-native expo


    【解决方案1】:

    此处正确的解决方法是切换到 deprecated-react-native-prop-types 或 Typescript 之类的类型系统。

    【讨论】:

    • 换句话说,按照错误消息的提示去做:p
    • @Jaromanda X 你能告诉我该怎么做吗?
    • 不要问我@justforhelp——不是我的答案——我只是指出这个答案正是错误消息所暗示的
    • @Jaromanda X 哦,我已经做到了,但仍然是同样的问题
    • 再次,不是我的答案,所以不是我的问题@justforhelp
    【解决方案2】:

    问题在于 react-native-snap-carousel。你有2个选择。您要么找到替代方案,要么导航到 node_modules/react-native-snap-carousel 并将所有导入更改为不推荐使用的类型。

    【讨论】:

      【解决方案3】:

      这帮助我解决了同样的问题,改用这个。

      npm i git+https://github.com/LarvenLLC/react-native-snap-carousel.git
      

      参考:https://github.com/meliorence/react-native-snap-carousel/pull/929#issuecomment-1221294797

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-11-20
        • 2018-12-08
        • 1970-01-01
        • 2018-03-26
        • 1970-01-01
        • 2018-10-27
        • 1970-01-01
        相关资源
        最近更新 更多