Here's the code sample and the JS version is working correctly.
The issue I encountered happening in TS :
import React from 'react'
class Parent extends React.Component {
render() {
return (
<Child Cpnt={<Header title='Header' />} />
/* TS error on Cpnt */
)
}
}
interface ChildProps {
Cpnt: React.ComponentClass
}
class Child extends React.Component <ChildProps> {
render () {
const { Cpnt } = this.props
return (
<div>
{{Cpnt}}
</div>
)
}
}
interface HeaderProps {
title: string
}
class Header extends React.Component <HeaderProps> {
render () {
const { title } = this.props
return (
<p>{title}</p>
)
}
}
I got an error on <Child Cpnt
[ts]
Type 'Element' is not assignable to type 'ComponentClass<{}, any>'.
Type 'Element' provides no match for the signature 'new (props: {}, context?: any): Component<{}, any, any>'. [2322]
What type should I defind here?
React.ReactElement