useController.d.ts 1.2 KB

123456789101112131415161718192021222324252627
  1. import { FieldPath, FieldValues, UseControllerProps, UseControllerReturn } from './types';
  2. /**
  3. * 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.
  4. *
  5. * @remarks
  6. * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
  7. *
  8. * @param props - the path name to the form field value, and validation rules.
  9. *
  10. * @returns field properties, field and form state. {@link UseControllerReturn}
  11. *
  12. * @example
  13. * ```tsx
  14. * function Input(props) {
  15. * const { field, fieldState, formState } = useController(props);
  16. * return (
  17. * <div>
  18. * <input {...field} placeholder={props.name} />
  19. * <p>{fieldState.isTouched && "Touched"}</p>
  20. * <p>{formState.isSubmitted ? "submitted" : ""}</p>
  21. * </div>
  22. * );
  23. * }
  24. * ```
  25. */
  26. export declare function useController<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: UseControllerProps<TFieldValues, TName>): UseControllerReturn<TFieldValues, TName>;
  27. //# sourceMappingURL=useController.d.ts.map