MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / dispatchEvent

Function dispatchEvent

code/third-party/public/app.js:5154–5178  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5152}
5153
5154function dispatchEvent(topLevelType, nativeEvent) {
5155 if (!_enabled) {
5156 return;
5157 }
5158
5159 var nativeEventTarget = getEventTarget(nativeEvent);
5160 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5161 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5162 // If we get an event (ex: img onload) before committing that
5163 // component's mount, ignore it for now (that is, treat it as if it was an
5164 // event on a non-React tree). We might also consider queueing events and
5165 // dispatching them after the mount.
5166 targetInst = null;
5167 }
5168
5169 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5170
5171 try {
5172 // Event queue being processed in the same cycle allows
5173 // `preventDefault`.
5174 batchedUpdates(handleTopLevel, bookKeeping);
5175 } finally {
5176 releaseTopLevelCallbackBookKeeping(bookKeeping);
5177 }
5178}
5179
5180var ReactDOMEventListener = Object.freeze({
5181 get _enabled () { return _enabled; },

Callers

nothing calls this directly

Calls 6

getEventTargetFunction · 0.70
isFiberMountedFunction · 0.70
batchedUpdatesFunction · 0.70

Tested by

no test coverage detected