React Native babelHelpers.asyncToGenerator is not a function (react-native 0.44.0)

I am new to react/react-native/babel world. I am trying to make async/await work.

package.json

{
  "name": "App",
  "version": "0.0.5",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.0.0-alpha.6",
    "react-native": "0.44.0",
    "react-native-fs": "^2.3.3"
  },
  "devDependencies": {
    "babel-jest": "20.0.3",
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-preset-react-native": "1.9.2",
    "babel-preset-stage-3": "^6.24.1",
    "jest": "20.0.3",
    "react-test-renderer": "16.0.0-alpha.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

.babelrc

{
  "presets": ["react-native", "babel-preset-stage-3"],
  "plugins": ["transform-async-to-generator"]
}

I tried different ways and at some point it seemed to work on the emulator, though it never worked on a real device. And now it doesn't work on either. I get:

babelHelpers.asyncToGenerator is not a function

I checked out everything including github ticket related to this problem and stackoverflow question (my question is not a duplicate as it's been awhile and I use different react-native version). None of it worked for me.


My question

So what would be a proper and most up-to-date way to enable async/await on React Native app?

install babel-preset-react-native-stage-0 and remove your babel-stage-3 preset Then you need to build / start your react app with --reset-cache option, and you should be good to go

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

React Native - Image Cache