Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: Missing class properties transform

I have problem with babel transform. After add handle event in my React container i got this error.

SyntaxError: Missing class properties transform.

  21 |     // handlers
  22 |
> 23 |     onIncrement = () => {
     |     ^
  24 |         const { dispatch } = this.props;
  25 |
  26 |         dispatch(valueDecrement())

My .babelrc

{
    "presets": [
        [
            "@babel/env",
            {
                "targets": {
                    "browsers": [
                      "last 2 versions"
                    ]
                }
            }
        ],

        "@babel/react",
        "@babel/typescript",
    ],
}

My webpack loader

...
    module: {
        rules: [
            {
                test: /\.(ts|js)x?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
            },
        ],
    },
...
like image 803
Oleg Ovcharenko Avatar asked Oct 26 '25 04:10

Oleg Ovcharenko


1 Answers

Solve. Need to install @babel/plugin-proposal-class-properties and add this plugin to the .babelrc. Link

like image 170
Oleg Ovcharenko Avatar answered Oct 27 '25 19:10

Oleg Ovcharenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!