extractEvents() — react Function Reference
Architecture documentation for the extractEvents() function in EnterLeaveEventPlugin.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 44ab0e04_cfdc_c2cb_fa50_605ef3be17ac["extractEvents()"] 5c7e27b3_eb27_811d_04b8_b882f63e7494["EnterLeaveEventPlugin.js"] 44ab0e04_cfdc_c2cb_fa50_605ef3be17ac -->|defined in| 5c7e27b3_eb27_811d_04b8_b882f63e7494 e68ee20d_0906_0494_d1c4_4f9c91467ead["extractEvents()"] 44ab0e04_cfdc_c2cb_fa50_605ef3be17ac -->|calls| e68ee20d_0906_0494_d1c4_4f9c91467ead 9ea33c9d_8861_07e4_cd82_238384a96c0f["isReplayingEvent()"] 44ab0e04_cfdc_c2cb_fa50_605ef3be17ac -->|calls| 9ea33c9d_8861_07e4_cd82_238384a96c0f fd46bf1d_69db_d76a_fbca_8de451c9f52e["isContainerMarkedAsRoot()"] 44ab0e04_cfdc_c2cb_fa50_605ef3be17ac -->|calls| fd46bf1d_69db_d76a_fbca_8de451c9f52e style 44ab0e04_cfdc_c2cb_fa50_605ef3be17ac fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js lines 48–171
function extractEvents(
dispatchQueue: DispatchQueue,
domEventName: DOMEventName,
targetInst: null | Fiber,
nativeEvent: AnyNativeEvent,
nativeEventTarget: null | EventTarget,
eventSystemFlags: EventSystemFlags,
targetContainer: EventTarget,
) {
const isOverEvent =
domEventName === 'mouseover' || domEventName === 'pointerover';
const isOutEvent =
domEventName === 'mouseout' || domEventName === 'pointerout';
if (isOverEvent && !isReplayingEvent(nativeEvent)) {
// If this is an over event with a target, we might have already dispatched
// the event in the out event of the other target. If this is replayed,
// then it's because we couldn't dispatch against this target previously
// so we have to do it now instead.
const related =
(nativeEvent: any).relatedTarget || (nativeEvent: any).fromElement;
if (related) {
// If the related node is managed by React, we can assume that we have
// already dispatched the corresponding events during its mouseout.
if (
getClosestInstanceFromNode(related) ||
isContainerMarkedAsRoot(related)
) {
return;
}
}
}
if (!isOutEvent && !isOverEvent) {
// Must not be a mouse or pointer in or out - ignoring.
return;
}
let win;
// TODO: why is this nullable in the types but we read from it?
if ((nativeEventTarget: any).window === nativeEventTarget) {
// `nativeEventTarget` is probably a window object.
win = nativeEventTarget;
} else {
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
const doc = (nativeEventTarget: any).ownerDocument;
if (doc) {
win = doc.defaultView || doc.parentWindow;
} else {
win = window;
}
}
let from;
let to;
if (isOutEvent) {
const related = nativeEvent.relatedTarget || (nativeEvent: any).toElement;
from = targetInst;
to = related ? getClosestInstanceFromNode((related: any)) : null;
if (to !== null) {
const nearestMounted = getNearestMountedFiber(to);
const tag = to.tag;
if (
to !== nearestMounted ||
(tag !== HostComponent && tag !== HostSingleton && tag !== HostText)
) {
to = null;
}
}
} else {
// Moving to a node from outside the window.
from = null;
to = targetInst;
}
if (from === to) {
// Nothing pertains to our managed components.
return;
}
let SyntheticEventCtor = SyntheticMouseEvent;
Domain
Subdomains
Source
Frequently Asked Questions
What does extractEvents() do?
extractEvents() is a function in the react codebase, defined in packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js.
Where is extractEvents() defined?
extractEvents() is defined in packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js at line 48.
What does extractEvents() call?
extractEvents() calls 3 function(s): extractEvents, isContainerMarkedAsRoot, isReplayingEvent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free