Skip to content Skip to sidebar Skip to footer

How To Use The Proposed Ecmascript Class Syntax With React And Webpack?

I am trying to learn the proposed class syntax for ecmascript and using it with React, i have successfully rendered components with es6 using babel with webpack. Now i want to use

Solution 1:

That syntax isn't "ES7" (by which I assume you mean ES2016, aka the 7th edition). In fact, it's not even ES2017. It's still a Stage 3 proposal. It might make ES2018 if a couple of implementations get done in time for it reach Stage 4 before the cutoff.

To use it with Babel, enable the stage-3 preset or the specific plugin for that feature (transform-class-properties).

Solution 2:

You will need the correct babel plugin for this.

npm install --save-dev babel-plugin-transform-class-properties

.babelrc

{"plugins":["transform-class-properties"]}

More information: https://babeljs.io/docs/plugins/transform-class-properties/

Post a Comment for "How To Use The Proposed Ecmascript Class Syntax With React And Webpack?"