preventDefault

A method on an event that cancels the browser's built-in action, such as submitting a form or following a link.

In more detail

Composed handlers check event.defaultPrevented so a consumer can opt out of a component's internal behaviour. It does not stop the event from bubbling to parents.

Examples

In the browser: It only works on cancelable events, and the defaultPrevented property shows whether it was called. Inside a passive listener the call is ignored, which is what lets the browser scroll without waiting.
When a React 19 form action prop is a function, React intercepts the submission itself, so the manual call is no longer needed.

Related terms

Taught in

References