In my post about using MobX in ReactJS to enable runtime style changes, I Ejected the Create-React-App in order to configure Webpack to enable Decorators, which Im using together with MobX. I found out that I could Quick-fix this without Ejecting.
Disclaimer: Im using the latest Create-React-App version; time of writing, this is version “react-scripts”: “0.6.1”
First of all you need to “npm install babel-plugin-transform-decorators-legacy –save”
After that is done, find these to configuration files:
- node_modules/react-scripts/config/webpack.config.dev.js
- node_modules/react-scripts/config/webpack.config.prod.js
With those 2 files open you need to add this line plugins: [‘transform-decorators-legacy’ ]
Have a look at these screenshots to find out where you must put them.
With those in place you should be able to use Decorators in your Create-React-App.