Skip to content

control

폼을 제어

</> control: Object

이 객체는 컴포넌트를 리액트 훅 폼에 등록할 수 있는 메소드들을 포함합니다.

RULES

Important: 직접 이 객체의 속성에 접근하지 마세요. 속성은 패키지 내부 용도로만 사용합니다.

Examples:


import React from "react"
import { useForm, Controller } from "react-hook-form"
import { TextField } from "@material-ui/core"
type FormInputs = {
firstName: string
}
function App() {
const { control, handleSubmit } = useForm<FormInputs>()
const onSubmit = (data: FormInputs) => console.log(data)
return (
<form onSubmit={handleSubmit(onSubmit)}>
<Controller
as={TextField}
name="firstName"
control={control}
defaultValue=""
/>
<input type="submit" />
</form>
)
}
import { useForm, Controller } from "react-hook-form"
function App() {
const { control } = useForm()
return (
<Controller
render={({ field }) => <input {...field} />}
name="firstName"
control={control}
defaultValue=""
/>
)
}

지원해 주셔서 감사합니다

프로젝트에서 React Hook Form이 유용하다고 생각하신다면, 스타를 눌러 지원해 주시길 부탁드립니다.