因为之前没有js的经验,所以踩坑较多,在此做个记录。
环境:
Visual stadio code(1.28.2) + Mac + React Native + 坚果pro
Q:VS Code在格式化代码的时候表现很怪异。
A:因为vs默认按照js进行格式化,所以我们需要将js设置为Javascreat React.
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
You likely forgot to export your component from the file it's defined in,
or you might have mixed up default and named imports.
A: 仔细对比之后,发现import的写法错误。
// 错误写法 import {NavigatorBar} from '../common/navigator'
------
//正确写法
import NavigatorBar from '../common/navigator'
see:https://blog.csdn.net/junhuahouse/article/details/80558233
Q:模拟器和真机上如何reload
A:模拟器上直接双击R即可,真机的话,左右摇动即可弹出reload选项。
还没有评论,来说两句吧...