Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

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

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

Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.

Examples

Example 1

function Input(props) {
  const { field, fieldState, formState } = useController(props);
  return (
    <div>
      <input {...field} placeholder={props.name} />
      <p>{fieldState.isTouched && "Touched"}</p>
      <p>{formState.isSubmitted ? "submitted" : ""}</p>
    </div>
  );
}

Type Parameters

optional
TFieldValues extends FieldValues = FieldValues
optional
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>

Parameters

  • the path name to the form field value, and validation rules.

Returns

field properties, field and form state. UseControllerReturn