TanStackT
TanStack9mo ago
6 replies
full-green

How to properly output error from useForm onSubmit

  const [error, setError] = useState("");
  const form = useForm({
    defaultValues: {
      email: "",
      password: "",
    },
    onSubmit: async ({ value }) => {
      const { error } = await authClient.signIn.email({
        email: value.email,
        password: value.password,
      });
      setError(error?.message || "Something went wrong");
    },
  });
Was this page helpful?