stopPropagation
An event method that stops the event from travelling to further elements, while other listeners on the current element still run.
In more detail
It does not cancel the browser's default action; that needs preventDefault. Use it sparingly: stopping bubbling can silently break delegated handlers and analytics higher up the tree.
Examples
The course uses it so a click inside a modal card does not reach the backdrop handler that closes the modal. In React it stops propagation through React handlers only; listeners attached directly to the document still receive the native event.onClick={(e) => e.stopPropagation()}Related terms
- stopImmediatePropagation() — An event method that stops the event travelling further and also skips any remaining listeners on the current element.
- preventDefault — A method on an event that cancels the browser's built-in action, such as submitting a form or following a link.
- event propagation — The journey of an event through the DOM: down from the window to the target (capturing), at the target, then back up (bubbling).
- event bubbling — The way an event on an element also triggers handlers on its parent elements, one level at a time up the tree.
Taught in
- Event Phases: Capturing, Target And Bubbling Demystified — Frontend Architecture & Web Platform
- SyntheticEvent System: Event Delegation in Modern React — React 19 & Modern Component Architecture
- React Portals: Escaping Stacking Contexts for Modals — React 19 & Modern Component Architecture