Hi I'm getting this error :
Type '{ children: Element; onClickOutside: () => void; }' is not assignable to type 'IntrinsicAttributes & PopUpWrapperProps'.
Property 'children' does not exist on type 'IntrinsicAttributes & PopUpWrapperProps'.ts(2322)
when trying to use <PopUpWrapper>
in InfoIcon.tsx
, I'm guessing it comes from a bad typing in withPortal.tsx
but I tried many things and didn't get the error to disappear...
Do you have any idea on how to solve this ?
withPortal.tsx
const withPortal = <P extends object>(Component : React.ComponentType<P>, querySelector = "#portal") => (props : P) => {
const isMounted = useMounted(null)
return isMounted && ReactDOM.createPortal(
<Component {...props}/>,
document.querySelector(querySelector)
)
}
export default withPortal
PopUpWrapper.tsx
interface PopUpWrapperProps {
onClickOutside: () => void
}
const PopUpWrapper : React.FC<PopUpWrapperProps> = ({children, onClickOutside}) => {
...
return <div className={styles.popup_wrapper} ref={ref} onClick={handleClick}>
{children}
</div>
}
export default withPortal(PopUpWrapper)
InfoIcon.tsx
interface InfoIconProps {
src: string,
alt: string
className?: string,
isProtected?: boolean
}
const InfoIcon : React.FC<InfoIconProps> = ({
src, alt, children, className = "", isProtected = true
}) => {
...
return <div className={styles.info_icon}>
...
{
identity === Identity.Testing &&
<PopUpWrapper onClickOutside={cancelIdendityTest}> //error here
<IdentityPopup />
</PopUpWrapper>
}
</div>
}
export default InfoIcon;
Just add children to your props type:
interface PopUpWrapperProps {
onClickOutside: () => void,
children: any
}