Babel Plugin Class Properties – React Arrow Functions

后端 未结 1 843
长情又很酷
长情又很酷 2020-12-19 13:42

I am running a React project using npm. After hours of research and experimenting, everywhere says I have to add the following code to my \".babelrc\" file, which I do not h

相关标签:
1条回答
  • 2020-12-19 14:12

    Found the solution to my question after 3 hours: –create a file called "babel.config.js" in the root directory. –put this in the file. –rerun the program (i.e. npm start).

    module.exports = {
      presets: [ "@babel/preset-env", "@babel/preset-react" ],
      plugins: [ "@babel/plugin-transform-arrow-functions", "@babel/plugin-proposal-    class-properties" ]
    }
    
    0 讨论(0)
提交回复
热议问题