event bubbling

The way an event on an element also triggers handlers on its parent elements, one level at a time up the tree.

In more detail

A click on a button runs handlers on the button, then on its parent, and so on up to the document, unless a handler calls stopPropagation. This lets one listener on a parent handle events for many children. React bubbles its own synthetic events along the component tree, so a click inside a portal still reaches handlers on the component that rendered the portal.

Examples

In the browser: Most events bubble, which is what makes event delegation work: a listener on a list sees clicks on every item. Some events, like focus, blur and scroll on elements, do not. A CustomEvent only bubbles if created with bubbles: true.
React events bubble through the React component tree, which is why events from a portal reach its React parent even though its DOM lives elsewhere.

Related terms

Taught in

References