useForm.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import { FieldValues, UseFormProps, UseFormReturn } from './types';
  2. /**
  3. * Custom hook to manage the entire form.
  4. *
  5. * @remarks
  6. * [API](https://react-hook-form.com/docs/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
  7. *
  8. * @param props - form configuration and validation parameters.
  9. *
  10. * @returns methods - individual functions to manage the form state. {@link UseFormReturn}
  11. *
  12. * @example
  13. * ```tsx
  14. * function App() {
  15. * const { register, handleSubmit, watch, formState: { errors } } = useForm();
  16. * const onSubmit = data => console.log(data);
  17. *
  18. * console.log(watch("example"));
  19. *
  20. * return (
  21. * <form onSubmit={handleSubmit(onSubmit)}>
  22. * <input defaultValue="test" {...register("example")} />
  23. * <input {...register("exampleRequired", { required: true })} />
  24. * {errors.exampleRequired && <span>This field is required</span>}
  25. * <button>Submit</button>
  26. * </form>
  27. * );
  28. * }
  29. * ```
  30. */
  31. export declare function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues = TFieldValues>(props?: UseFormProps<TFieldValues, TContext>): UseFormReturn<TFieldValues, TContext, TTransformedValues>;
  32. //# sourceMappingURL=useForm.d.ts.map