(Typescript) Only allow a specific html element in children
Unanswered
White-tailed Tropicbird posted this in #help-forum
White-tailed TropicbirdOP
Hello,
I'm making something that requires the
I tried this:
but this doesn't seem to work. I can just put a
How do I enforce specific children in my component?
I'm making something that requires the
html element to be inside of my Layout component, is there any way to enforce this?I tried this:
export const Layout = ({
children,
}: {
children: ReactElement<HTMLHtmlElement>;
}) => { /* ... */ }but this doesn't seem to work. I can just put a
div inside of my Layout and typescript doesn't show any errors.How do I enforce specific children in my component?
1 Reply
you can only enforce the children to have specific props, but not to be a specific type