【React Native】Rreact Native 常見錯誤總結

1.invariant violation:expected a component class,got[object object]
創建自定義組件首字母要大寫,否則會報錯.


2.Module 0 is not a registered callable module.
將gradle升級成最新版本(cd Android 進入android目錄執行:sudo./gradlew clean) 或者通過android studio工具升級.


3.android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
       該錯誤屬於安卓Native的錯誤,如果引用的Activity不存在或者已經銷燬,再次引用就會報該錯誤,如果是React Native 調用原生控件的話,創建控件需要引用:getCurrentActivity()



4.android.app.Application cannot be cast to com.facebook.React.ReactApplication
需要將創建的MainApplication在AndroidManifest.xml配置好.


5.Element type is invalid: expected a string (for built-in components) or a class/function but got: object
發生原生一般是你引用了無效的組件,如果組件確實正確,看下引用的組件是否正常導出:(export defalut)


6.react native  undefined is not an object (evaluating this....
發生該錯誤的一般是忘記bind(this),只要回調函數中需要用到this的,一般都需要bind.


7.react native - expected a component class, got [object Object]
該錯誤可能是你引用了小寫的組件,組件首字母一定要大寫,比如<login/>應該寫成<Login/>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章