Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the experimental syntax 'classProperties' isn't currently enabled #44

Closed
SampsonCrowley opened this issue Nov 27, 2018 · 3 comments

Comments

@SampsonCrowley
Copy link

this is something that is DEFINITELY in CRA

ideas?

./src/lib/components/modal-editor/modal-editor.js
SyntaxError: /home/samps/modules/react-component-templates/library/src/lib/components/modal-editor/modal-editor.js: Support for the experimental syntax 'classProperties' isn't currently enabled (9:20):

   7 |
   8 | export default class ModalEditor extends Component {
>  9 |   static propTypes = {
     |                    ^
  10 |     onClose: PropTypes.func.isRequired,
  11 |     changed: PropTypes.bool,
  12 |     heading: PropTypes.any,

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

@hodgef
Copy link

hodgef commented Nov 28, 2018

Hey @SampsonCrowley,

This is not supported by CRA v2 by default, since it's experimental syntax.
facebook/create-react-app#4648

However, I fixed this in my boilerplate since I needed this asap (https://github.com/hodgef/js-library-boilerplate)

Basically, add this to your package.json

"babel": {
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
    ],
    "plugins": [
      [
        "@babel/plugin-proposal-class-properties"
      ]
    ]
  }

and this to your webpack.config.demo

loader: require.resolve('babel-loader'),
....
presets: [
    "@babel/preset-env",
    "@babel/preset-react"
],
plugins: [
    [
    "@babel/plugin-proposal-class-properties"
    ]
],

then run npm install

Regards

@SampsonCrowley
Copy link
Author

SampsonCrowley commented Dec 4, 2018

@hodgef i can say with 100% certainty that is supported by v2 off the bat. I have not added anything to my babel config, or the plugins in my package.json for any of the CRA apps i'm currently building and they all work just fine with class properties

notice line 21 in babel preset react-app used by CRA:
https://github.com/facebook/create-react-app/blob/master/packages/babel-preset-react-app/package.json

@SampsonCrowley
Copy link
Author

@hodgef after rereading that thread I think I found the source of my confusion. application code does indeed have it enabled as I have verified, but library code specifically doesn't

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants