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

Function dispatchEvent

code/controlled-uncontrolled/public/app.js:5245–5269  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5243}
5244
5245function dispatchEvent(topLevelType, nativeEvent) {
5246 if (!_enabled) {
5247 return;
5248 }
5249
5250 var nativeEventTarget = getEventTarget(nativeEvent);
5251 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5252 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5253 // If we get an event (ex: img onload) before committing that
5254 // component's mount, ignore it for now (that is, treat it as if it was an
5255 // event on a non-React tree). We might also consider queueing events and
5256 // dispatching them after the mount.
5257 targetInst = null;
5258 }
5259
5260 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5261
5262 try {
5263 // Event queue being processed in the same cycle allows
5264 // `preventDefault`.
5265 batchedUpdates(handleTopLevel, bookKeeping);
5266 } finally {
5267 releaseTopLevelCallbackBookKeeping(bookKeeping);
5268 }
5269}
5270
5271var ReactDOMEventListener = Object.freeze({
5272 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