react native 的那些坑(持续更新)
最近一直在用react native写一个移动app,碰到不少问题。所以想开个博客记录一下碰到的问题和解决办法,有错误的话还请指正。
-
Could not run adb reverse
adb不能直接打开app,代码不能热更新。
解决方法: 发现环境变量地址/
方向有误,按照react native官网重新配置环境变量解决。setting,连接同一wifi,把地址设为电脑ip,也可以解决,但麻烦的是每次都要重新设置。 -
Package com.hagnosticnews signatures do not match the previously installed version
出现原因:寝室电脑开发,换到实验室开发出现
解决办法: adb uninstall 包名 -
Activity class {XX.MainActivity} does not exist.
解决办法: adb uninstall 包名 真好用 -
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of “XXX"
看了其他帖子,大多都是import和export default 的错误,仔细检查也未发现有相关错误,最后还是选择排除法debug,不断的注释掉代码,结果发现注释掉自己封的一个title组件后,程序正常运行,结果发现是这个组件引入路径多写了一级,导致有个组件引入失败。
before
import { TitleBar,Button } from '../../../my-components/Button';
after
import { TitleBar,VzButton } from '../../../my-components';