Skip to content
Discussion options

You must be logged in to vote

Yes, it is expected because you provide the generic.

getValues: UseFormGetValues<TFieldValues>;

If you remove the generic type, react hook form will infer the type based on defaultValues

  const { getValues } = useForm({
    defaultValues: {
      foo: undefined,
    },
  });

  const values = getValues(); 

In my experience, the best way to solve this type of mismatching with the generic is just providing {foo: ''} if the field is a simple input component. Then you can avoid this.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@tykhan
Comment options

@sujinleeme
Comment options

@tykhan
Comment options

@sujinleeme
Comment options

Answer selected by tykhan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants