im using react and i try to make form with custom submit button (with div)
but when i submit the form the page automatically refreshes, despite e.preventDefault
my code :
<form onSubmit={e => e.preventDefault()} className="form">
<div
onClick={e => {
e.preventDefault();
document.querySelector(".form").submit();
}}
id="button"
>
Submit
</div>
</form>
demo on code sandbox : https://codesandbox.io/s/bitter-pond-9fcnr
button?submitevent is bypassed)... You do know you can style buttons, too, right?