drcmda / react-contextual

🚀 react-contextual is a small (less than 1KB) helper around React 16s new context api
MIT License
642 stars 23 forks source link

"Cannot call class as function" when extending @subscribe'd class? #35

Open benallfree opened 5 years ago

benallfree commented 5 years ago

I'm getting an unexpected error when inheriting from a @subscribe'd class, can anyone tell me if I'm doing this right?

https://codesandbox.io/s/9ynn07091o

import React, { Component } from "react";
import ReactDOM from "react-dom";
import { Provider, subscribe } from "react-contextual";

const props = {
  test: "hello"
};

@subscribe()
class A extends Component {
  render() {
    const { test } = this.props;
    return test;
  }
}

class B extends A {}

ReactDOM.render(
  <Provider {...props}>
    <B />
  </Provider>,
  document.getElementById("root")
);
TypeError
Cannot call a class as a function