I’m currently using React with Typescript, and realize I can define the props for a component in such a way that extends the default properties of an HTML element, like so:
type TextInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
label?: string
description?: string
}
const TextInput = ({
label,
description,
...props
}: TextInputProps) => {
return (
<div>
{/* omitting unnecessary code */}
<input
className={`flex-shrink:0 border-gray-3 border-radius: 0.25rem h-9 w-full rounded`}
{...props}
/>
</div>
)
}
However I’m clueless as to where I can find such interfaces like React.InputHTMLAttributes<HTMLInputElement>
to use when I create other components using native HTML elements.
Is there documentation for something like this, or a cheat sheet online? I want quick and easy access, because I know I speak for other developers when I say I won’t be able to remember half of these interfaces names hahaha.
Thanks