4

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',
            },
        ],
    },
...
2

1 Answer 1

12

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

Sign up to request clarification or add additional context in comments.

1 Comment

1. npm install --save-dev @babel/plugin-proposal-class-properties 2. webpack.config.js -> module -> rules -> loader -> options -> plugins: ["@babel/plugin-proposal-class-properties"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.