-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorators are not supported yet in 6.x pending proposal update. #105
Comments
found the solution:
# .babelrc
{
"presets": [
"react",
"es2015",
"stage-1"
],
"plugins": ["transform-decorators-legacy"]
} |
Thanks for figuring this out! I updated the tests and will update the docs soon |
@kmalakoff ^ how to enable decorators in babel 6 |
no problem, glad it helped |
As reported here: mobxjs/mobx-react#41 it appears that the order of plugins is important, make sure that |
I have the save problem.
|
I had this come up in my react-native project, after adding a new preset to my
|
So with this setup you don't need Op do 6 okt. 2016 om 00:04 schreef Adam Wilson notifications@github.com:
|
No, that's what |
i have tried everything in this thread and i still get "leading decorators must be attached to a class" i m on latest everything. any suggestions? i would hate to go to redux. |
@nikitph note that all decorators are optional! See http://mobxjs.github.io/mobx/best/decorators.html |
i know.. but i m from a java background and find decorators to be much more On Tue, Oct 25, 2016 at 10:47 AM, Michel Weststrate <
|
Can you share your setup and config files? React / react Native / Op di 25 okt. 2016 om 21:23 schreef nikit notifications@github.com:
|
Hi guys,
For this bit of code:
I got this output: |
@DigitalMarc afaik |
@mweststrate cheers, all that MobX stuff is great and I would definitely like having those decorators working. |
@DigitalMarc are you using react or react-native? Are you sure |
hey @mweststrate, thanks for your feedback. I'm using react, testing next.js so the problem might come from there. Babel presets are loaded for the 'package.json' file located at the root of the project structure. I've installed all the Babel package I can dream of and tested different combination. |
@DigitalMarc ah! check: vercel/next.js#26. Edit: see you already found it. Yeah I think the issue is probably that the plugins don't get the right priority. If it is just for testing / play, you might try to modify the babelrc of next itself in your node_modules (or by creating a fork), that should give some clue whether this is indeed the issue |
@mweststrate, Thanks mate, I'll give a try. |
Install
|
if use
|
My solution was
webpack.config.js
So added |
Hey guys, i got a problem about mobx envirnoment.
And i intall babel-preset and babel-plugin which is needed. After test, i could use decorator in my project. But when it comes to mobx use like
I got output |
You need babel-plugin-transform-class-properties
… On Nov 15, 2017, at 08:25, chen tuo ***@***.***> wrote:
Hey guys, i got a problem about mobx envirnoment.
I have .babelrc file like this
{
"presets": ["es2015"],
"plugins": ["transform-decorators-legacy"]
}
And i intall babel-preset and babel-plugin which is needed. After test, i could use decorator in my project. But when it comes to mobx use like
import { observable } from 'mobx';
export default class Timer {
@observable timer = 0;
}
I got output SyntaxError: index.js: Unexpected token at timer = 0, what should i do to fix it? I have knowed that decorator should work with class/function, Any extra configuration is needed whe n i want to create observable properties?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
If anyone have question like me? You may need add |
@cpprookie I got the same error and fixed it,thank you |
please make sure that
You can read more here |
tried to configure my .babelrc file.. for using decorators in mobx project Plugin/Preset files are not allowed to export objects, only functions. |
I config my .babelrc files like this: Anyone can help me ? Thanks. |
Just tried mobservable in my project, though ran into this issue:
Module build failed: SyntaxError:
Decorators are not supported yet in 6.x pending proposal update.
Here is my
.babelrc
:The text was updated successfully, but these errors were encountered: