简体   繁体   中英

Setting up ReactJS with MobX decorators without TypeScript?

I have read this tutorial , and it seems like it doesn't work for me, probably because its outdated.

I get the following error when using the @inject decoration:

./src/index.js
Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'.

I can't really find a way to properly set up decorations for mobX without using TypeScript?

Use babel and it's plugins to transpile your code.

To use decorators use @babel/plugin-proposal-decorators

In your babelrc file add plugins property:

{
  // your other babel settings
  "plugins": ["plugin-proposal-decorators"]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM