Closed SampsonCrowley closed 5 years ago
Hey @SampsonCrowley,
This is not supported by CRA v2 by default, since it's experimental syntax. https://github.com/facebook/create-react-app/issues/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
@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
@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
this is something that is DEFINITELY in CRA
ideas?