I am trying to dynamically import a React Component from a module like this:
state: {
OsdComponent: React.Component<any, any>
}
constructor(props) {
super(props)
this.state = {
OsdComponent: null,
}
}
async componentWillMount() {
const {OsdComponent} = await import(`manifest-viewer`)
this.setState({OsdComponent})
}
and then try to use it like this in render:
render() {
const {OsdComponent} = this.state
if (OsdComponent) {
<OsdComponent/>
}
}
but Typescript compile fails with 'TS2604: JSX element type 'OsdComponent' does not have any construct or call signatures.'
The code works in another module that is not compiled with Typescript.
class MyComponent extends React.Component<..., ...>). - Matt McCutchen