Skip to content
Discussion options

You must be logged in to vote

It seems from your code snippet that submitting the form by pressing "Enter" would always submit the form via onSubmitFunctionOne (or whatever the default value for the useState hook is set to).

In that case it would be the same as having:

<form onSubmit={handleSubmit(onSubmitFunctionOne)}>
  <button type="submit" />
  <button type="button" onClick={handleSubmit(onSubmitFunctionTwo)} />
</form>

If each button is only linked to one function, then you would know/be able to infer which button was clicked by which function was called, right?

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@neilwiborg
Comment options

@h-mack
Comment options

Answer selected by neilwiborg
@neilwiborg
Comment options

@k-wakamatsu-tms
Comment options

@h-mack
Comment options

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