Home > Mobile >  Solid JS equivalent of React.HTMLProps<...>
Solid JS equivalent of React.HTMLProps<...>

Time:01-24

I have a React component with prop types like:

type Props = React.HTMLProps<HTMLAnchorElement> & {
    to?: string;
};

How do you write the equivalent prop types in SolidJS? I tried this:

type Props = Component<HTMLAnchorElement> & {
    to?: string;
};

And it compiles, but it does not have the same built in props as the former such as children.

CodePudding user response:

Solid JS has JSX.IntrinsicElements which provides properties types indexed by tag name:

import { JSX } from 'solid-js';

type Props = JSX.IntrinsicElements['a'] & {
    to?: string;
};
  •  Tags:  
  • Related