Skip to content

useForm with zod and typescript #589

Answered by crutchcorn
kuamanet asked this question in Q&A
Discussion options

You must be logged in to vote

This appears to be a bug with our types, not a limitation with our API.

const { isIdle, mutate: authenticate } = useMutation<undefined | string, DefaultError, LoginFormDto>({
    mutationFn: async dto => {
      return await authenticationRepository.authenticate(dto);
    },
  });

  const form = useForm({
    validatorAdapter: zodValidator,
    validators: {
      onChange: loginFormSchema,
    },
    onSubmit: ({ value }) => {
      authenticate(value);
    },
  });

This code should work as-intended with value defined properly and onChange executing for the whole app.

Could you open a GH issue reporting this bug so we can investigate?

Actually, before you do could you confirm for me th…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by crutchcorn
Comment options

You must be logged in to vote
1 reply
@crutchcorn
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants