The onSubmit handler on the form element will be triggered by clicking the submit button or pressing the Enter key inside a form input. Similarly like onChange prop, onSubmit will provide us the submit event when called. In order to stop the page from refreshing, we need to call its native method event.preventDefault().