I'm searching for a way to retrieve the type of my children's prop. I've created a component that can receive as children a single react element or an array of React elements with specific props. According to the type of my children, I need to perform different actions. How can I understand the type of my children?
const CodeFragmentsWrapper: React.FC<{ children?: React.ReactElement<MyProps> | React.ReactElement<MyProps>[] }> = (props) => {
return (
<div>
{
children.isAnArray //HOW TO DO THIS? (or something similar)
? //DO SOMETHING
: //DO SOMETHING ELSE
}
</div>
);
}