React-Native 常见问题总结

来源:互联网 发布:95579交易软件下载 编辑:程序博客网 时间:2024/05/18 09:04

React Native 常见问题集合

http://www.cnblogs.com/lovesong/p/5679340.html

常见错误

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]

该错误可能是你引用了小写的组件,组件首字母一定要大写,比如应该写成

原创粉丝点击