How to use 'Container(flux/utils)' in TypeScript?

Viewed 236

test.tsx

import * as React from 'react';
import { Container } from 'flux/utils';

class TestComponent extends React.Component< any, any > {
  constructor(props, context) {
    super(props, context);
    this.state = { test : 0 };
  }
  public static getStores() {
    return;
  }
  public static calculateState() {
    return {
      // counter: CounterStore.getState(),
  };
  render() {
    return <span>Test</span>
  }
}

const App = Container.create(TestComponet);// Error
export default App;

Error

TS2345: Argument of type 'typeof TestComponent' is not assignable to parameter of type '(ComponentClass & ComponentStatic & typeof TestComponent) | (StatelessComponent & C...'. Type 'typeof TestComponent' is not assignable to type 'StatelessComponent & ComponentStatic & typeof TestComponent'. Type 'typeof TestComponent' is not assignable to type 'StatelessComponent'. Type 'typeof TestComponent' provides no match for the signature '(props: any, context?: any): ReactElement'.

So, I cannot use Container.create(). What's wrong my code.

0 Answers
Related