ref을 붙여야 하는 component를 forwardRef으로 만든다.
const Input = forwardRef((props:ComponentProps<any>,ref) => {
return (
<StyledInput ref={ref} id={props.id} name={props.name} autoComplete={"off"} maxLength={props.maxlength} onBlur={props.onBlur} onChange={props.onChange} {...props}></StyledInput>
)
});
export default Input;
이러고
<Input ref={emailRef} name="email" type="email" width={"200px"} auto="off" id="Email" maxlength="50" onBlur={onBlur} onChange={onChange} ></Input>
이런식으로 ref을 붙이면 된다.