What are synthetic events in React?
IntermediateReact interview questionBy UIRound, updated 17 November 2026
Short answer
A synthetic event is the object React passes to your handlers, such as onClick and onChange. It wraps the browser's native event and gives it the same interface in every browser: target, currentTarget, preventDefault(), stopPropagation(). React does not attach a listener to each element. Since React 17 it listens once at the root container and dispatches events through the component tree itself.
What the wrapper is
function SaveButton() {
function handleClick(event) {
event.preventDefault();
console.log(event.type); // "click"
console.log(event.currentTarget); // the <button>
console.log(event.nativeEvent); // the browser's MouseEvent
}
return <button onClick={handleClick}>Save</button>;
}The synthetic event has the properties you know from the DOM (clientX, key, button, shiftKey and so on) and the methods preventDefault() and stopPropagation(). If you need something the wrapper does not expose, event.nativeEvent is the original browser event.
React created the wrapper for two reasons. Browsers used to differ in event properties and behaviour, and the wrapper hid those differences. It also lets React control when and in what order handlers run, which matters for batching state updates and for features such as portals.
Root delegation since React 17
React uses event delegation. When you render into a root, React adds one listener per event type to the root container element. When a click happens, the native event bubbles up to the root, React finds the component that was clicked, and then walks up the React tree calling each onClick and onClickCapture it meets, in capture and bubble order.
Before React 17, these listeners were on document. Moving them to the root container fixed two practical problems:
- Several React apps on one page, or React inside a non-React app, no longer interfere with each other's events.
stopPropagation()now behaves as expected for native listeners ondocument. Calling it in a React handler stops the native event before it reachesdocument, because the event is still at the root when React handles it.
One consequence remains: a native listener attached directly to an element with addEventListener runs before React handlers in the bubble phase, because React handles the event only when it reaches the root.
Event pooling was removed in React 17
React 16 and earlier reused synthetic event objects for performance. After the handler returned, every property was set to null, so this failed:
function handleChange(event) {
setTimeout(() => {
console.log(event.target.value); // React 16: error, target is null
}, 100);
}You had to call event.persist() to keep it. React 17 removed pooling because it brought no real speed benefit in modern browsers and confused people. Since then you can read the event in a timeout or after an await. persist() still exists but does nothing. You will still see it in old code and in interview questions about older versions.
Differences from native events
| Behaviour | Native DOM | React |
|---|---|---|
change on a text input |
Fires when the input loses focus after a change | onChange fires on every keystroke, like the native input event |
| Stop default action | return false works in inline onclick attributes |
Must call event.preventDefault(); returning false does nothing |
| Naming | onclick attribute with a string |
onClick prop with a function |
| Focus events | focus and blur do not bubble |
onFocus and onBlur bubble (React uses focusin and focusout) |
| Scroll | scroll does not bubble |
onScroll does not bubble since React 17 |
| Portals | Bubble up the DOM tree | Bubble up the React tree, through the portal's owner |
| Capture phase | addEventListener(type, fn, true) |
onClickCapture, onKeyDownCapture and so on |
The portal row surprises people most. A click inside a modal rendered with createPortal into document.body still reaches the onClick of the component that rendered the modal, even though the DOM nodes are not nested. See What are portals in React?.
The onChange row matters for controlled components: React needs the value on every keystroke to keep state and input in sync.
Practise it
Build a synthetic event system with root delegation makes you implement the dispatch React does. Predict React event order checks how React and native listeners interleave, and Stop clicks inside a portal modal from triggering the parent's onClick covers the portal case.
Common follow-up questions
How do you type a synthetic event in TypeScript?
Use React's event types with the element type: React.MouseEvent<HTMLButtonElement>, React.ChangeEvent<HTMLInputElement>, React.FormEvent<HTMLFormElement>. They are not the same as the DOM's MouseEvent.
Is event. target the same as event. currentTarget?
event. target the same as event. currentTarget?No. target is the innermost element where the event started, for example an icon inside a button. currentTarget is the element whose handler is running. In TypeScript, currentTarget has the precise element type, so prefer it for reading the element you attached the handler to.
How do you listen to window or document events in React?
window or document events in React?Add a native listener in useEffect and remove it in the cleanup. Those events are outside React's tree, so there is no prop for them.
Does stopPropagation in React stop native listeners?
stopPropagation in React stop native listeners?It stops native listeners above the root, such as on document and window. It cannot stop native listeners on elements inside the root, because those already ran before the event reached the root.
Mistakes to avoid
Returning
falsefrom a handler and expecting the default action to stopCalling
event.persist()in new code, or believing events are still pooledExpecting
onChangeto fire on blur like the nativechangeeventForgetting that portal events bubble to React ancestors
Mixing native
addEventListenerand React handlers on the same elements without knowing the order
Sources
Practise it in code
Interviewers rarely stop at the definition. These questions open in an editor with tests.
- Build a synthetic event system with root delegation, capture and bubble phases, and
stopPropagationHard60 min - Predict React event order: capture and bubble handlers,
stopPropagation, and native listeners on the same elementsMedium25 min - Stop clicks inside a portal modal from triggering the parent's
onClickMedium25 min