记录学习RN遇到的报错

格式:【描述】 【截图】 【解决】 【参考】

ios

android

关键词:override

【描述】

Native module VectorIconsModule tried to override VectorIconsModule for module name RNVectorIconsModule. If this was your intention,set canOverrideExistingModule=true

【截图】

【解决】

找到MainApplication.java(android/app/src/main/java/com),里面有有重复的引用,把重复的部分删除就行了

import com.oblador.vectoricons.VectorIconsPackage;// 删除
...
public class MainApplication extends Application implements ReactApplication {
    ...
    new VectorIconsPackage(),// 删除
}

【参考】

https://stackoverflow.com/que...

关键词:refs

【描述】

addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method,or you have multiple copies of React loaded (details: https://fb.me/react-refs-must...

【截图】

【解决】

<View ref={"abcd"}/>  

this.refs.abcd    // 如果在rander之外使用ref就会报错报错

改成:

myRefs = {
    abcd: null
}

<View ref={(abcd) => {this.myRefs.abcd = abcd}}>

this.myRefs.abcd

相关文章

一、前言 在组件方面react和Vue一样的,核心思想玩的就是组件...
前言: 前段时间学习完react后,刚好就接到公司一个react项目...
前言: 最近收到组长通知我们项目组后面新开的项目准备统一技...
react 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...