I have added the conditon to check the header and footer is value or not
const hasHeader = !!(children as React.ReactNode[]).find((e) =>
isComponentType(el, Header)
);
return {
header,
};
}, [children]);```
CodePudding user response:
const hasChildComponent = (Component) => {
return !!(children as React.ReactNode[]).find((el) => isComponentType(el, Component));
}
return {
hasHeader: hasChildComponent(Modal.Header),
hasFooter: hasChildComponent(Modal.Footer),
}