Arrow Function syntax not working with webpack?

后端 未结 5 763
渐次进展
渐次进展 2020-11-28 11:10

I\'m making an app on react-redux. I\'m using webpack for bundling and babel for transpiling. When I am try to use arrow function in my code. It gives me error as :

5条回答
  •  攒了一身酷
    2020-11-28 11:51

    Also if you want to get used to new babel show, you can use babel.config.js file instead of .babelrc. The idea is like something like webpack.config.js file , but for babel configurations. It is been used like below:

    module.exports = {
      presets: [ "@babel/preset-env", "@babel/preset-react" ],
      plugins: [ "@babel/plugin-transform-arrow-functions", "@babel/plugin-proposal-class-properties" ]
    }
    

    Make sure to install all of those plugins to compile successfully. I should say that babel itself just recommended to do all of these stuff in .babelrc file to every one. But you know, we are not every one.

提交回复
热议问题