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

Taught in

References