Mobx: The Decorators is error in React-native project

Created on 6 Dec 2017  Â·  2Comments  Â·  Source: mobxjs/mobx

"mobx": "^3.3.1",
"mobx-react": "^4.3.4",
"react": "16.0.0",
"react-native": "0.50.3",
"react-native-blur": "^3.2.2"

In the IOS simulator has the error unexpected token, and my code is :
image

the error is(homeStore.js):
image

Most helpful comment

You will need to enable decorators in your setup. Which is probably doing something like:

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

Create a .babelrc in your project directory with these options:

{
 "presets": ["react-native"],
 "plugins": ["transform-decorators-legacy"]
}

If you already have some plugins, it is important that the decorators plugin comes first

See for example: https://moduscreate.com/blog/using-es2016-decorators-in-react-native/

All 2 comments

You will need to enable decorators in your setup. Which is probably doing something like:

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

Create a .babelrc in your project directory with these options:

{
 "presets": ["react-native"],
 "plugins": ["transform-decorators-legacy"]
}

If you already have some plugins, it is important that the decorators plugin comes first

See for example: https://moduscreate.com/blog/using-es2016-decorators-in-react-native/

@Hancoson you should close the issue if the comment helped. The decorators certainly work with RN with the babel plugin.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

giacomorebonato picture giacomorebonato  Â·  3Comments

etinif picture etinif  Â·  3Comments

mehdi-cit picture mehdi-cit  Â·  3Comments

ariona picture ariona  Â·  3Comments

josvos picture josvos  Â·  3Comments