Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/deps/react-hook-form.ts>UseFormRegister

Deno-powered framework for building business web apps
Go to Latest
type alias UseFormRegister
import { type UseFormRegister } from "https://deno.land/x/netzo@0.3.91/deps/react-hook-form.ts";

Register field into hook form with or without the actual DOM ref. You can invoke register anywhere in the component including at useEffect.

Examples

Example 1

// Register HTML native input
<input {...register("input")} />
<select {...register("select")} />

// Register options
<textarea {...register("textarea", { required: "This is required.", maxLength: 20 })} />
<input type="number" {...register("name2", { valueAsNumber: true })} />
<input {...register("name3", { deps: ["name2"] })} />

// Register custom field at useEffect
useEffect(() => {
  register("name4");
  register("name5", { value: '"hiddenValue" });
}, [register])

// Register without ref
const { onChange, onBlur, name } = register("name6")
<input onChange={onChange} onBlur={onBlur} name={name} />

Type Parameters

TFieldValues extends FieldValues
definition: <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: RegisterOptions<TFieldValues, TFieldName>) => UseFormRegisterReturn<TFieldName>