same type props as typescript code example
Example 1: react typescript props
type CarProps = {
name: string;
brand: string;
price;
}
const Car: React.FC<CarProps> = (props) => {
const { name, brand, price } = props;
}
const Car: React.FC<CarProps> = ({ name, brand, price }) => {
}
Example 2: ts react props type
type Props = {
size: string;
}
const Component = ({ size = 'medium' }: Props) => (
<div className={cn('spinner', size)} />
);
Example 3: get typescript props of component
type ViewProps = React.ComponentProps<typeof View>
type InputProps = React.ComponentProps<'input'>