In React. How to check each child's, in children array, type at runtime with TypeScript?

95 Views Asked by At

I would like to know if there is a way to check types in runtime with TypeScript in this scenario. The scenario is just for illustrative purposes.

const SomeReactComponent = ({ children, inverseOrientation }) => {
    const header = findByType('ComponentHeader', children);
    const content = findBytype('ComponentContent', children);
    const footer = findByType('ComponentFooter, children);

    if(inverseOrientation) return <div> {[footer,content,header]} </div>;
    return <div>{children}</div>;
}
0

There are 0 best solutions below