错误:
已弃用的react原生道具类型
";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/areact native snap carousel/src/index.js";,它抛出了一个异常:不变冲突:ViewPropTypes已从中删除React Native。迁移到导出自的ViewPropTypes"已弃用的react本机道具类型"。
打开文件
./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';
它会起作用。。。
这是旧npm包的一个错误,如果项目是活动的,那么开发人员会在新版本中修复它。当你将软件包更新到新的软件包时,这个错误可能会消失
我找到了这个错误的解决方案安装typescript包应该还安装解决错误的类型定义snap crusel库的"已弃用的react原生道具类型">
$ 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时,你必须对出现相同错误的库再次执行这些步骤
答案如下安装此程序包不推荐使用react本机道具类型,如果您安装了新的程序包,请搜索此程序包以替换以下模块。这些是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;
},
};