Static method is undefined in ES6 classes with a decorator in reactjs Static method is undefined in ES6 classes with a decorator in reactjs reactjs reactjs

Static method is undefined in ES6 classes with a decorator in reactjs


If you're using babel with es6, it could be transpiled like that (to es5):

var MyComponent = (function () {  function MyComponent() {    _classCallCheck(this, _MyComponent);  }  _createClass(MyComponent, null, [{    key: 'foo',    value: function foo() {      return "FOO";    }  }]);  var _MyComponent = MyComponent;  Foo = withStyles(MyComponent) || MyComponent;  return MyComponent;})();

So its problem is that withStyles(MyComponent) will return another function which obviously doesn't have static methods you specified for original class.