0
7
register(form, "example"); handleSubmit(register); watch(register, "submit"); control(register, "submit", { message: "Your input has been submitted!" });
register stores the reference to the form object.
handleSubmit is called when the user submits the form. It registers a function to be called when the submit event is triggered.
watch is used to keep an eye on the register object and trigger the function registered when the submit event is triggered, based on the value of the register field.
control is used to bind the register field to a function that can be called to handle the submission of the form. In this case, the function will print out a message stating that the user's input has been submitted.
Library: react
Shortcut: react.form.hook.use
import { useForm } from 'react-hook-form';
const { register, handleSubmit, watch, control } = useForm();