#React component types dynamically

2 messages · Page 1 of 1 (latest)

hushed osprey
#
<Input inputChange={inputChange} id="email" name="email" autoComplete="email" placeholder="Email address" type="email" roundClass="rounded-t-md" />
<Input inputChange={inputChange} id="email" name="descripion"  placeholder='Video Title' type="text"  />

As shown in the image, sometimes I want AuthInputPropsType and sometimes I want inputTypes props types.

and this is my input components

import { AuthInputPropsType } from "../types/props/formPropsTypes"



const Input =  (props:AuthInputPropsType ) => {
 const {id,name,type,autoComplete,placeholder,roundClass,inputChange} = props
  return (
    <input
    id={id}
    name={name}
    type={type}
    autoComplete={autoComplete}
    required
    className={`login-input ${roundClass}`}
    placeholder={placeholder}
    onChange={inputChange}
  />
  )
}

export default Input;
#

is there any option to do with typescript generics??