【RN】Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager.

目录

1. 问题

2. 解决


1. 问题

最近在写RN 的过程中,隔了好长时间今天要改点东西,一跑环境,我嚓,报如下错误:

Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager.

还原代码,搞事情

结果还是没有解决,折腾了好久,都是因为要与时俱进:

npm update

搞事;

2. 解决

步骤:

1. 使用如下命令,检查项目依赖有哪些:

npm ls > npm_dependence.log

2. 更新后发现当前项目下有几个依赖包更新了,定位到具体包:

npm ls @ant-design/react-native

...
+-- @ant-design/[email protected]
+-- @ant-design/[email protected]   // 之前是 3.1.15 版本
| +-- @ant-design/[email protected] deduped
| +-- @bang88/[email protected]
| +-- @bang88/[email protected]
| +-- @react-native-community/[email protected]
| +-- [email protected]
| +-- [email protected]
...

项目中原来要求是:

@ant-design/[email protected]

3. 卸载 @ant-design/[email protected] 包,安装 @ant-design/[email protected] 包:

// 卸载 @ant-design/[email protected]
npm uninstall @ant-design/[email protected]

// 安装 @ant-design/[email protected]
npm install @ant-design/[email protected]

然后,重启VS + RN 环境

次哦,还是不行;

4. 终极大法,删除项目目录下的 node_modules ,注意,是项目目录下的 node_modules,然后安装node 项目环境:

npm i

然后,重启VS + RN 环境

次哦,还是不行;

5. 终极大法,哪行报错删哪行,我的是由于使用了第三方组件View 导致的,所以不用第三方,二分法排除问题,空View 堆叠;

保存,然后回显页面,然后再还原代码,在进行回显页面,问题解决;

卸载,安装,之后问题,是缓存的导致的问题;

(完)

发布了66 篇原创文章 · 获赞 17 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/DovSnier/article/details/103069439
今日推荐