Skip to content
Discussion options

You must be logged in to vote

I just pass an empty function to be explicit about what happens on submit: onSubmit={() => {}}.

In HTML5 a form's default action is to submit a GET request to the current page (99% of the time, not what you want, and can be a security risk if you aren't aware this will happen). Unfortunately, in React Native that doesn't mean anything. In React Native the default action is nothing because there is no <form /> element. Formik works in both of these places and would have different behaviors without an onSubmit, so we strongly recommend (read, require in TypeScript) that you pass an onSubmit. Note that it technically doesn't have different behaviors because we do not fall back to form.submit…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@pierroberto
Comment options

@johnrom
Comment options

johnrom Mar 22, 2021
Collaborator

Answer selected by pierroberto
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