Article From:https://segmentfault.com/q/1010000010349394
Question:


Excuse me, who has met with me to see the configuration of official documents or not?

Answer 0:

CRAThe decorator is not allowed because it is not stable enough. You can use the decorator.

Answer 1:

I can refer to my project (referencing the decorator)

rc-admin

The project will not update regularly, and more modules will be added later.

If there is a problem, add QQ group 221859379 to communicate with me

If it is helpful to you, give it to star.

Answer 2:

By the way, does babel-plugin-transform-decorators-legacy have NPM install?

Answer 3:

You can addtransform-decorators-legacy It’s yours.node_modules/react-scripts/config/babel.dev.js andbabel.prod.js,The code is as follows:

  • Add the following code topresets:
require.resolve('babel-preset-stage-1'),
require.resolve('babel-preset-es2015')
  • Add the following code toplugins The first line:
require.resolve('babel-plugin-transform-decorators-legacy'),

You can refer to my demo:https://github.com/Hancoson/r.

Leave a Reply

Your email address will not be published. Required fields are marked *