I'm using withFormik and I currently have 2 separate submit buttons in my form, and I need to identify which one has been clicked in my handleSubmit function, but event data isn't passed along. Any ideas how I could do that?
Thanks!
Funny, I just ran into this issue with Redux-Form so I thought I would take a look at this library to see how they handled it.
You can make your own handler that calls submitForm instead of using handleSubmit
Getting the event object inside of handleSubmit would be useful in some cases.
These tend to be edge cases where you should call your own handler and submitForm
Why not pass event object as a third argument to onSubmit (handleSubmit)?
Let me give an example:
There is non-standard feature in Chrome, called "Credentials API", which allows developer to save and use passwords to/from browser. One of constructors for PasswordCredential (docs) accepts HTMLFormElement. So I need to pass HTML form to it, in case authorisation was successful and I want to save credentials. So how am I supposed to write my own handler, if I need HTML form _inside_ submitForm, to pass it to my API/service call/action?
I can make PR for that
Most helpful comment
Why not pass event object as a third argument to
onSubmit(handleSubmit)?Let me give an example:
There is non-standard feature in Chrome, called "Credentials API", which allows developer to save and use passwords to/from browser. One of constructors for
PasswordCredential(docs) accepts HTMLFormElement. So I need to pass HTML form to it, in case authorisation was successful and I want to save credentials. So how am I supposed to write my own handler, if I need HTML form _inside_ submitForm, to pass it to my API/service call/action?I can make PR for that