I have a component like this:
type TPage = {
title: string;
};
const Page = React.memo(({ children, title, ...rest }: TPage) => {
return (
<div {...rest}>
<div>{title}</div>
{children}
</div>
);
});
And I use it as,
<Page
title="Title"
style={{
minHeight: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "column"
}}
>
<div>Some content</div>
</Page>
This throws an error,
const Page = React.memo(({ children, title, ...rest }: TPage) => {
^^^^^^^^
Property 'children' does not exist on type 'TPage'
I've tried fixing it by changing TType to,
type TPage = React.PropsWithChildren<{
title: string;
children: React.ReactNode;
}>;
This fixed the issue with children, but it started complaining for the style prop, saying
Property 'style' does not exist on type 'IntrinsicAttributes
& { title: string; children: ReactNode; } & { children?: ReactNode; }'
What am I doing wrong here?