Foundations: Component Lifecycle & Synthetic Events
Component Lifecycle & Synthetic Events: Master event delegation and component life-cycle behavior in declarative code.
In vanilla JavaScript, managing a user interface means imperatively binding event listeners (addEventListener), manually querying the DOM, and tearing down observers whenever elements leave the screen.
Modern React inverts this model completely:
- Declarative Synchronization Over Imperative Timelines: Instead of juggling discrete lifecycle hooks (componentDidMount, componentWillUnmount), components synchronize internal state with external systems through declarative effect boundaries.
- **Centralized Delegation Over Node Binding:** Rather than attaching individual listeners across hundreds of DOM nodes, React intercepts, normalizes, and bubbles interactions through its centralized SyntheticEvent engine.
## 1. React's SyntheticEvent System & Event Delegation
When you pass an onClick=\{handleClick\} handler to 500 rows in a data table, React does not invoke element.addEventListener('click', ...) 500 times. Doing so would consume substantial memory and introduce garbage-collection drag.
Instead, React combines Event Delegation with a cross-browser wrapper: the SyntheticEvent.
### 1.1 The Delegation Architecture: Root-Level Trapping
In React 17, 18, and 19, event listeners attach directly to the root DOM container where the application mounts (document.querySelector('#root')), rather than to the global document node (as in React 16).
```text
[ Native Browser Click on
