MENU
Differences from HTML events
React events differ from built-in HTML events in three ways:
The names of React events are in camelCase rather than lowercase.
The value of a React event attribute is specified as a JSX function name rather than a parenthesized function string.
We cannot return false to prevent the default behavior in React. Use e.preventDefault() instead.
Original HTML event handling:
RESETRUNFULL
RESETRUNFULL
<form onsubmit="handleSubmit() return false;">
<button>Submit</button></form>
React event handling:
RESETRUNFULL
RESETRUNFULL
function Form() {
function handleSubmit(e) {
e.preventDefault();
}
return (
<form onSubmit={handleSubmit}>
<button>Submit</button>
</form>
);}