import { useForm } from "https://deno.land/x/netzo@0.5.70/deps/react-hook-form.ts";
Custom hook to manage the entire form.
Examples
Example 1
Example 1
function App() {
const { register, handleSubmit, watch, formState: { errors } } = useForm();
const onSubmit = data => console.log(data);
console.log(watch("example"));
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input defaultValue="test" {...register("example")} />
<input {...register("exampleRequired", { required: true })} />
{errors.exampleRequired && <span>This field is required</span>}
<button>Submit</button>
</form>
);
}
Type Parameters
optional
TFieldValues extends FieldValues = FieldValuesoptional
TTransformedValues extends FieldValues | undefined = undefinedParameters
optional
props: UseFormProps<TFieldValues, TContext>- form configuration and validation parameters.
Returns
methods - individual functions to manage the form state. UseFormReturn