how I get input field type as the props in react typescript I tried to send type as the string but it gives this error
**
No overload matches this call. Overload 1 of 2, '(props: InputProps | Readonly): Input', gave the following error. Type 'string' is not assignable to type '"number" | "button" | "select" | "textarea" | "time" | "image" | "text" | "hidden" | "color" | "email" | "file" | "radio" | "checkbox" | "reset" | "submit" | "date" | "datetime-local" | ... 8 more ... | undefined'. Overload 2 of 2, '(props: InputProps, context: any): Input', gave the following error. Type 'string' is not assignable to type '"number" | "button" | "select" | "textarea" | "time" | "image" | "text" | "hidden" | "color" | "email" | "file" | "radio" | "checkbox" | "reset" | "submit" | "date" | "datetime-local" | ... 8 more ... | undefined'. TS2769
**
here is my code
import React from 'react';
import { Input } from 'reactstrap';
interface IconInputProps {
name: string,
label: string,
placeholder: string,
required: boolean,
errorMessage: string,
autoFocus: boolean,
type: string
icon: string
}
class IconInput extends React.Component<IconInputProps> {
render() {
return (
<div>
<Input
name={this.props.name}
lable={this.props.label}
type={this.props.type}
placeholder={this.props.placeholder}
/>
</div>
);
}
}
export default IconInput;
input
(ordinary HTML element) requires type as a string (I checked on codesandbox and my local), butInput
(the one from 'reactstrap' you're using is requiring a more concrete type). – hungdoansy