Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

useForm

Custom hook to manage the entire form.

@example
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>
  );
}
function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>(props?: UseFormProps<TFieldValues, TContext>): UseFormReturn<TFieldValues, TContext, TTransformedValues>;
§
useForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>(props?: UseFormProps<TFieldValues, TContext>): UseFormReturn<TFieldValues, TContext, TTransformedValues>
[src]

§Type Parameters

§
TFieldValues extends FieldValues = FieldValues
[src]
§
TContext = any
[src]
§
TTransformedValues extends FieldValues | undefined = undefined
[src]

§Parameters

§
props?: UseFormProps<TFieldValues, TContext> optional
[src]
  • form configuration and validation parameters.

§Return Type

§
UseFormReturn<TFieldValues, TContext, TTransformedValues>
[src]

methods - individual functions to manage the form state. UseFormReturn