create-react-app中使用@connect修饰器解决

2019-07-30  本文已影响0人  _一九九一_

使用@connec的时候有报错:

安装依赖:

修改文件:

// 代码片段
{ 
   "babel": {
      "presets": [ "react-app"  ],
      "plugins": [
         ["@babel/plugin-proposal-decorators",  { "legacy": true  }   ],   // 增加配置
         [ "@babel/plugin-proposal-class-properties", {  "loose": true  } ]  // 增加配置
      ]
   }
}

高阶组件的写法:

export const wrapAuth = ComposedComponent => {
   @connect class  AuthButton extends Component{
   
   } 
  return AuthButton
}
上一篇 下一篇

猜你喜欢

热点阅读