React Native 0.69.1 我面临问题“deprecated-react-native-prop-types”

问题描述 投票:0回答:4

错误

已弃用-react-native-prop-types

"react-native": "0.69.1",----这个错误仅出现在最新版本的react-native中

I am facing this issues when I installed any of this library
-react-native-snap-carousel
-react-native-fast-image

需求模块 “node_modules/react-native-snap-carousel/src/index.js”,这引发了 异常:不变违规:ViewPropTypes 已从 反应本机。迁移到从以下位置导出的 ViewPropTypes “已弃用-react-native-prop-types”。

react-native react-proptypes react-native-snap-carousel react-native-fast-image
4个回答
2
投票

打开文件

./node_modules/react-native-snap-carousel/src/carousel/Carousel.js 
./node_modules/react-native-snap-carousel/src/Pagination/Pagination.js
./node_modules/react-native-snap-carousel/src/Pagination/PaginationDot.js
./node_modules/react-native-snap-carousel/src/ParallaxImage/ParallaxImage.js

编辑

import { ... ,ViewPropTypes } from 'react-native';

import { ... } from 'react-native';
import {ViewPropTypes} from 'deprecated-react-native-prop-types';

它会起作用...


0
投票

这是旧 npm 包的错误,如果项目还活着,那么开发人员会在新版本中修复它。当您将软件包更新到较新的软件包时,也许这个错误就会消失。

我找到了这个错误的解决方案安装打字稿包应该 还安装解决错误的类型定义 'deprecated-react-native-prop-types' 用于 snap crousel 库

$ npm install --save @types/react-native-snap-carousel
    
         **THIS IS WORKING PERFECT FOR ME**

我更喜欢采用第一种方法

或者您可以采用不同的方法

在节点模块中查找 ViewPropTypes 导入,该模块在哪个库中出现错误 从“react-native”中删除导入此文件并创建新的导入

import {ViewPropTypes} from 'react-native';
import {ViewPropTypes} from 'deprecated-react-native-prop-types';

它也工作得很好,但是当您再次安装新包或 npm install 时,您必须对给出相同错误的库再次执行此步骤


0
投票

这就是答案 安装这个包deprecated-react-native-prop-types并且如果你安装一个新的包搜索这个替换下面的模块。这些是

node_modules/react-native/index.js

的更改
diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..1bc8c9d 100644
--- a/node_modules/react-native/index.js
+++ b/node_modules/react-native/index.js
@@ -435,32 +435,16 @@ module.exports = {
   },
   // 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'.",
-    );
+    return require('deprecated-react-native-prop-types').ColorPropType;
   },
   get EdgeInsetsPropType(): $FlowFixMe {
-    invariant(
-      false,
-      'EdgeInsetsPropType has been removed from React Native. Migrate to ' +
-        "EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').EdgeInsetsPropType;
   },
   get PointPropType(): $FlowFixMe {
-    invariant(
-      false,
-      'PointPropType has been removed from React Native. Migrate to ' +
-        "PointPropType exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').PointPropType;
   },
   get ViewPropTypes(): $FlowFixMe {
-    invariant(
-      false,
-      'ViewPropTypes has been removed from React Native. Migrate to ' +
-        "ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').ViewPropTypes;
   },
 };

0
投票

安装@4.0.0-beta.6版本

npm install -save [email protected]
© www.soinside.com 2019 - 2024. All rights reserved.