I am trying to handle submitting a form in React. The form has two buttons which traditionally would send the form to two different locations using formaction
. How can I get the formaction
of the button the form is submitted in my onSubmit
function in React?
onSubmit = (e) => {
e.preventDefault();
if (formaction === 'download') {
...
} else if (formaction === 'stop') {
...
}
}
render() {
return (
<Form onSubmit={this.onSubmit}>
...
<Button formAction="download" type="submit">Download</Button>
<Button formAction="stop" type="submit">Stop</Button>
</Form>
);
)