React to solve the problem using the ES7 decorator Methods
method one:
1.yarn eject or npm run eject
2. Add in the package.json
"babel": { "plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }] ], "presets": [ "react-app" ] }
Method Two:
1. Modify package.json
“scripts”: {
“eject”: “react-scripts eject”,
“start”: “react-app-rewired start”,
“build”: “react-app-rewired build”,
“test”: “react-app-rewired test”
}
2. Install rely on a number of related babel
yarn add @babel/plugin-proposal-decorators -D
3. Installation customize-cra and react-app-rewired
yarn add react-app-rewired customize-cra -D
Add config-overrides.js (must package.json the same level) in the root directory
content:
const { override, addDecoratorsLegacy } = require('customize-cra')
module.exports = override(addDecoratorsLegacy())
4. The installation of decorative Recommended core-decorators some of which comes decorators
yarn add core-decorators -D
Summary: decorators can use in react when you complete the steps above