React Native 填坑大全(持续更新)

1、引入mobx,支持ES7 decorator的报错问题

安装以下包(yarn or npm)
yarn add module:metro-react-native-babel-preset @babel/preset-flow @babel/plugin-proposal-decorators --dev

创建 .babelrc文件
{
  "presets": [
    "module:metro-react-native-babel-preset",
    "@babel/preset-flow"
  ],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy" : true }]
  ]
}


2、使用导航栏组件react-navigationstackNavigator报错

stackNavigator 因为涉及到客户端手势操作,
需导入react-native-gesture-handler

1. yarn add react-native-gesture-handler
2. react-native link react-native-gesture-handler
3. 查看iOS工程的Podfile文件是否引入
pod 'React', :path => '../node_modules/react-native', :subspecs => [
    . . . // other subspecs
    'RCTLinkingIOS',
    . . .
  ]
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
4. 进行pod install
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容