With React version 18, there is no more intrinsic prop
and no more children
prop.
children
propchildren
prop is a special prop automatically passed to component to represent any nested elements or components inside the parent component.
TS2559: Type ReactElement<any, any> has no properties in common with type { children?: ReactNode; }
Implicit properties are built-in attributes on HTML elements like id
, className
, style
, onClick
, href
have to be explicitly referenced and typed.
// previously <ParentComponent> <Children className={"flex"}> {someValue} </Children> </ParentComponent> function Children(props) { return ( <div>{props.children}</div> ) } // after React 18 <ParentComponent> <Children className={"flex"}> {someValue} </Children> </ParentComponent> function Children( { children } : { className: string } & PropsWithChildren // from react package ) { return( <div>{children}</div> ) }