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

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

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useForm
import { useForm } from "https://deno.land/x/netzo@0.4.72/deps/react-hook-form.ts";

Custom hook to manage the entire form.

Examples

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 = FieldValues
optional
TContext = any
optional
TTransformedValues extends FieldValues | undefined = undefined

Parameters

  • form configuration and validation parameters.

Returns

methods - individual functions to manage the form state. UseFormReturn