~/alexsh.blog

$ cat react-internals/08-event-system.md

Event System

February 9, 20261 min readpart 08/13

React doesn't attach listeners to individual DOM nodes. It uses event delegation — a single listener on the root container for each event type, registered during createRoot().

When a native event fires and bubbles to the root, React constructs a SyntheticEvent, walks the Fiber tree from target to root collecting handlers, and dispatches them in order (capture then bubble). Different events get different priorities: discrete events (click, keydown) → SyncLane, continuous events (mousemove, scroll) → InputContinuousLane.

Further reading