tezvyn:

Direct events vs bubbling events in native components

AI-drafted, machine-checkedSource: interviewadvanced
WHAT IT TESTS

native UI event semantics.

OUTLINE

direct events fire only on the originating component; bubbling events propagate up the component tree like the DOM, allowing parent capture.

WHAT THIS TESTS: Knowledge of how custom native components register events and how React Native's event system propagates them through the component tree.

A GOOD ANSWER COVERS: When you expose events from a native UI component, you classify them as direct or bubbling. Direct events are delivered only to the specific component instance that produced them; they do not travel up the tree, so only the handler on that component fires. Bubbling events propagate upward through ancestor components, similar to how DOM events bubble, meaning a handler on a parent or wrapping component can also receive and respond to the event. You declare the event type in the component configuration, and the choice is about semantics: who is allowed to react to the event.

COMMON WRONG ANSWERS: Believing direct events also bubble. Treating the distinction as a performance setting rather than a propagation model. Assuming bubbling events can be captured downward; React Native's model bubbles upward. Forgetting that event names must be registered for the component.

LIKELY FOLLOW-UPS: How event names map between native and JS, how this is declared in the new architecture with CodeGen, whether you can stop propagation, and how synthetic events carry payloads.

ONE CONCRETE EXAMPLE: A custom video player emits onLoad as a direct event because only the player itself should learn that its media finished loading. The same player emits onPress as a bubbling event so that a parent card component wrapping the player can also respond, for instance navigating to a detail screen when any part of the card, including the player, is tapped.

Read the original → reactnative.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.