const element = React.Children.map(children, (child) => { --> if (child.type !== CardFooter) return React.cloneElement(child); });
child & child.type prompts TS error.
"Property 'type' does not exist on type 'string | number | boolean |{} | ReactElement<any,string | JSXElementConstructor> |ReactPortal'.
Property 'type' does not exist on type 'string'. ts(2339)"
Update:Use the isValidElement type guard to bypass this problem.
//Like thisconst element = React.Children.map(children, (child) => { if (React.isValidElement(child)) { if (child.type !== CardFooter) return React.cloneElement(child); } });