React syntax error when adding class properties

后端 未结 2 1331
借酒劲吻你
借酒劲吻你 2020-12-21 15:42

I\'m writing a react app with babel and webpack. It\'s been going along well until I tried to add a property on a class - specifically trying to use a Dropdown from React-To

2条回答
  •  一个人的身影
    2020-12-21 16:15

    I would make sure you have babel set up right. You're probably missing the plugin for class properties, which is an experimental feature.

    .babelrc

    {
      "presets": ["react", "es2015"],
      "plugins": ["transform-class-properties"]
    }
    

    You can get the plugin via npm: npm i -D babel-plugin-transform-class-properties

提交回复
热议问题