To check the type of a React component,. we can use the type property.
For instance, we write
import MyComponent from "./MyComponent";
//...
this.props.children.forEach((child) => {
if (child.type === MyComponent) {
console.log("This child is <MyComponent />");
}
});
to check the type property of each child in the children prop to see if it’s MyComponent.
If it is, then the child is a MyComponent instance.