As you mentioned in the comment, you're not actually working with components, but with elements. In this case, you'll want to use React.ReactElement
instead of React.Component
. An element is an instance of a component.
interface props {
data: Array<string | number> | Array<React.ReactElement>
}
Your use case sounds like you may be just looking for the type for "anything that I can render". In this case, use React.ReactNode
:
interface props {
data: Array<React.ReactNode>
}
If you only want string | number | React.ReactElement
but not false
, true
, null
, etc., use React.ReactChild
instead of React.ReactNode
, as it covers string | number | ReactElement
interface props {
data: Array<React.ReactChild>
}
For more details about their differences, see When to use JSX.Element vs ReactNode vs ReactElement?