Check The Type Of A Child Component
import React from 'react';
const Hello = () => <h1>Hello</h1>;
const Greeting = ({ children }) => {
let hello;
React.Children.forEach(children, child => {
if(child.type === Hello) {
hello = child;
}
});
return hello;
};if(child.type === Hello || child.type === <Hello />.type)Last updated