記錄學習RN遇到的報錯

格式:【描述】 【截圖】 【解決】 【參考】java

ios

關鍵詞:EMFILE

【描述】 react

ERROR Error watching file for changes: EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"Error watching file for changes:","filename":null}
Error: Error watching file for changes: EMFILEandroid

at _errnoException (util.js:1041:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1359:9)

【截圖】 ios

圖片描述

【解決】 git

升級最新MacOS系統後,須要從新安裝一次brew install watchmangithub

或者segmentfault

須要安裝watchmanapp

git clone https://github.com/facebook/w...
cd watchman
./autogen.sh
./configure
make
sudo make installide

【參考】this

https://segmentfault.com/q/10...

android

關鍵詞:override

【描述】

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

【截圖】

clipboard.png

【解決】

找到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...

【截圖】

clipboard.png

【解決】

<View ref={"abcd"}/>  

this.refs.abcd    // 若是在rander以外使用ref就會報錯報錯

改爲:

myRefs = {
    abcd: null
}

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

this.myRefs.abcd
相關文章
相關標籤/搜索