I would like to prevent my submit button from refreshing my page when I click submit.
This is what I have tried
const formSubmit = e => {
e.preventDefault();
const newSubmission = {
x: horizontal,
y: vertical,
steps: count,
email: email.trim(),
}
// console.log(newSubmission)
postNewSubmission(newSubmission);
}
and my input:
<input id="submit" onSubmit={formSubmit} type="submit"></input>
For added context, clicking on submit should send some data to an API and receive some response hence why I am calling postNewSubmission.
To reiterate, the issue is that everytime I click submit it refreshes my page – which is not I what I want – I would like to prevent this default behavior