submit
여부를 자동으로 관리해줌form
데이터를 관리하는 하나의 객체
const SomeComponent = () => {
const {
handleSubmit,
control,
formState: { errors },
getValues,
} = useForm<IJoin>();
return (<>...</>)
}
control
: 해당 컴포넌트와 useForm
을 연결handleSubmit
: 제출시 발생하는 이벤트 핸들러. 일반적으로 button
의 onPress
에서 활용export interface IJoin {
phoneNumber: string;
email: string;
passwordRepeat: string;
passWord: string;
nickName: string;
verification: string;
}
기타 자세한 메서드는 API Doc 참조
https://react-hook-form.com/api/useform
<Controller
control={control}
render={({ field: { onChange, onBlur, value } }) => (
<Input
type={type}
onBlur={onBlur}
value={value}
onChange={onChange}
placeholder={placeholder}
error={errors[name]?.message}
/>
)}
name={name}
rules={rules}
/>