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

2019-02-25  本文已影响0人  Angrybaby

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
上一篇下一篇

猜你喜欢

热点阅读