MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / dispatchEvent

Function dispatchEvent

code/new-context-api/public/app.js:5282–5306  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5280}
5281
5282function dispatchEvent(topLevelType, nativeEvent) {
5283 if (!_enabled) {
5284 return;
5285 }
5286
5287 var nativeEventTarget = getEventTarget(nativeEvent);
5288 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5289 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5290 // If we get an event (ex: img onload) before committing that
5291 // component's mount, ignore it for now (that is, treat it as if it was an
5292 // event on a non-React tree). We might also consider queueing events and
5293 // dispatching them after the mount.
5294 targetInst = null;
5295 }
5296
5297 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5298
5299 try {
5300 // Event queue being processed in the same cycle allows
5301 // `preventDefault`.
5302 batchedUpdates(handleTopLevel, bookKeeping);
5303 } finally {
5304 releaseTopLevelCallbackBookKeeping(bookKeeping);
5305 }
5306}
5307
5308var ReactDOMEventListener = Object.freeze({
5309 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