Skip to content

What to do when submit on a form MUST call a client-side function? #333

Answered by airjp73
JUNIORCO asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

You can use onSubmit as you normally would, but with async superpowers.

return (
  <ValidatedForm
    validator={signInValidator}
    onSubmit={async (validatedData, event) => {
      event.preventDefault();
      await signIn(validatedData);
    }}
  >
    <FormInput name="email" label="Email" />
    <FormInput name="password" label="Password" />
    <FormSubmitButton />
  </ValidatedForm>
  );

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JUNIORCO
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