NinetyHH NinetyHH - 1 month ago 13
React JSX Question

React-Native: Cannot update babel to ES7

I am trying to use the new ES7 features async/await but as far as I can see in my react-native node_modules, I don't have them there.

I had the react-native version 0.31 and I just updated it to 0.32, I can see that babel still is not updating with the ES7 features so I cannot use the async/await. Do you know a way how I can manage to make it work?


You need to install a couple of babel plugins, then you can use ES7 decorators and save it in devDependencies:

1- babel-plugin-transform-decorators-legacy

npm i babel-plugin-transform-decorators-legacy --save-dev

2- babel-preset-react-native-stage-0

npm i babel-preset-react-native-stage-0 --save-dev

Finally Create .babelrc in root project folder file if not exist and add these lines:

 'presets': ['react-native'],
 'plugins': ['transform-decorators-legacy']