Ben Beri
Ben Beri

Reputation: 1201

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?

Upvotes: 0

Views: 539

Answers (1)

Javid Asgarov
Javid Asgarov

Reputation: 1532

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"]
}

Upvotes: 1

Related Questions