How to Prevent Form to Reload Page After Onsubmit

Prevent page reload on form submission

It looks like in your constructor you are binding the function wrong:

this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleChange.bind(this);

The second function needs to bind against handleSubmit instead

Prevent form from being refreshing when submitted in Reactjs

Add an onSubmit event handler on the form ,

<form onSubmit={handleOnsubmit}> </form> 

in your handleOnsubmit function perfrom event.preventDefault()

function handleOnsubmit(event) {

event.preventDefault();
// Do Whatever you want
}


Related Topics



Leave a reply



Submit