React native 0.69.1我遇到了“deprecated-react-native-prop-types”问题

cxfofazt  于 6个月前  发布在  React
关注(0)|答案(4)|浏览(136)

错误
deprecated-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”,引发异常:Invariant Violation:ViewPropTypes已从React Native中删除。迁移到从'deprecated-react-native-prop-types'导出的ViewPropTypes。

nafvub8i

nafvub8i1#

打开文件

./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';


会成功的

tkqqtvp1

tkqqtvp12#

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

我发现这个错误的解决方案安装typescript软件包还应该安装类型定义,以解决snap crousel库的错误'deprecated-react-native-prop-types'

$ 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安装再次你必须做这个步骤againn的库,这给出了同样的错误

wqlqzqxt

wqlqzqxt3#

这里是答案安装这个软件包deprecated-react-native-prop-types和如果u安装一个新的软件包搜索这个替换下面的模块.这些是为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;
   },
 };

字符串

42fyovps

42fyovps4#

安装@4.0.0-beta.6版本

npm install -save [email protected]

字符串

相关问题