Arrow Function syntax not working with webpack?

Stab in the dark, is this function inside a class? Arrow functions that are members of a class are not included in ES2015 (or 2016). If you want to do something like:

class Foo {
  bar = (baz) => {
    console.log(baz);
  } 
}

You’ll need to include babel-transform-class-properties.

In your example, you’ll need to:

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

and change your loader to

{
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        query: {
          presets: ['react', 'es2015', 'react-hmre'],
          plugins: ['transform-class-properties']
        }
      }

Leave a Comment