Careeroza
React 17+
What Changed
Modern browsers do not need pooling, and it confused developers, so React 17 removed event pooling. Events can be read anywhere, any time. e.persist() still exists but does nothing.
Example
In React 17+ (this preview uses React 18) reading the event inside a timeout works.
export default function App() {
const handleChange = (e) => {
setTimeout(() => console.log('value later:', e.target.value), 500);
};
return <input placeholder="Type something" onChange={handleChange} />;
}Result
Event Delegation Change
| React 16 | React 17+ | |
|---|---|---|
| Event pooling | yes (needs e.persist()) | no |
| Listeners attached to | document | the root container (#root) |
| Effect | multiple React versions on a page conflicted | safe to embed several React apps |
Note: React never adds a listener to every button: it uses event delegation, one listener per event type at the root, and dispatches to your handlers.