React-hook-form: why is `useForm` not taking type arguments?

Asked
Active3 hr before
Viewed126 times

2 Answers

react
90%

I'm implementing a basic user signup form with react-hook-form in Typescript. The following code works fine:,Making statements based on opinion; back them up with references or personal experience., Is it possible for user written algorithms to outperform libraries' built-in optimized functions?

Pretag
 Pretag team - issue, fix, solve, resolve
88%

By setting shouldUnregister to true at useForm level, defaultValues will not be merged against submission result.,useForm is custom hook for managing forms with ease. It takes optional arguments. The following example demonstrates all of the arguments along with their default values.,defaultValues will be shallowly merged with form submission data.

useForm({
  mode: 'onSubmit',
  reValidateMode: 'onChange',
  defaultValues: {},
  resolver: undefined,
  context: undefined,
  criteriaMode: "firstError",
  shouldFocusError: true,
  shouldUnregister: false,
  shouldUseNativeValidation: false,
  delayError: undefined
})type FormInputs = {
  firstName: string;
  lastName: string;
};

const { register } = useForm<FormInputs>({
  mode: 'onSubmit',
  reValidateMode: 'onChange',
  defaultValues: {},
  resolver: undefined,
  context: undefined,
  criteriaMode: "firstError",
  shouldFocusError: true,
  shouldUnregister: false,
  delayError: undefined
})
load more v

Other "react-undefined" queries related to "React-hook-form: why is `useForm` not taking type arguments?"