import { useController } from "https://deno.land/x/netzo@0.3.91/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
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 = FieldValuesoptional
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>Parameters
props: UseControllerProps<TFieldValues, TName>
- the path name to the form field value, and validation rules.
Returns
field properties, field and form state. UseControllerReturn