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

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

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

Component based on useController hook to work with controlled component.

Examples

Example 1

function App() {
  const { control } = useForm<FormValues>({
    defaultValues: {
      test: ""
    }
  });

  return (
    <form>
      <Controller
        control={control}
        name="test"
        render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
          <>
            <input
              onChange={onChange} // send value to hook form
              onBlur={onBlur} // notify when input is touched
              value={value} // return updated value
              ref={ref} // set ref for focus management
            />
            <p>{formState.isSubmitted ? "submitted" : ""}</p>
            <p>{fieldState.isTouched ? "touched" : ""}</p>
          </>
        )}
      />
    </form>
  );
}

type

<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: ControllerProps<TFieldValues, TName>) => import("https://esm.sh/v128/@types/react@18.2.38/X-ZS9yZWFjdCxyZWFjdC1kb20/index.d.ts").ReactElement<any, string | import("https://esm.sh/v128/@types/react@18.2.38/X-ZS9yZWFjdCxyZWFjdC1kb20/index.d.ts").JSXElementConstructor<any>>