因为之前没有js的经验,所以踩坑较多,在此做个记录。
环境:
Visual stadio code(1.28.2) + Mac + React Native + 坚果pro


Q:VS Code在格式化代码的时候表现很怪异。
A:因为vs默认按照js进行格式化,所以我们需要将js设置为Javascreat React.
React-native使用过程中踩的坑


Q: 我明明导入了模块,但是运行时候提示我没有导入模块。

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选项。


相关文章:

  • 2021-09-16
  • 2021-09-17
  • 2021-10-10
  • 2019-06-04
  • 2021-04-28
  • 2018-08-20
  • 2018-11-05
猜你喜欢
  • 2021-09-15
  • 2021-08-01
  • 2022-01-12
  • 2021-09-22
  • 2021-08-13
  • 2021-07-12
  • 2020-01-01
相关资源
相似解决方案