I have a function that conditionally renders/returns a string or a dynamic component depending on what type the prop is:
const renderValue = (value: string | React.ReactNode) => {
if (React.isValidElement(value)) {
const Component = value
return <Component />
}
return value
}
However, with the above code I get the following message from Typescript:
JSX element type 'Component' does not have any construct or call signatures.ts(2604)
I have read other answers on this topic on SO, but still haven't concluded an answer.