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

Function dispatchEvent

code/higher-order-components/public/app.js:5915–5939  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5913}
5914
5915function dispatchEvent(topLevelType, nativeEvent) {
5916 if (!_enabled) {
5917 return;
5918 }
5919
5920 var nativeEventTarget = getEventTarget(nativeEvent);
5921 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5922 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5923 // If we get an event (ex: img onload) before committing that
5924 // component's mount, ignore it for now (that is, treat it as if it was an
5925 // event on a non-React tree). We might also consider queueing events and
5926 // dispatching them after the mount.
5927 targetInst = null;
5928 }
5929
5930 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5931
5932 try {
5933 // Event queue being processed in the same cycle allows
5934 // `preventDefault`.
5935 batchedUpdates(handleTopLevel, bookKeeping);
5936 } finally {
5937 releaseTopLevelCallbackBookKeeping(bookKeeping);
5938 }
5939}
5940
5941var ReactDOMEventListener = Object.freeze({
5942 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