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

Function dispatchEvent

code/one-direction-data-flow/public/app.js:5794–5818  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5792}
5793
5794function dispatchEvent(topLevelType, nativeEvent) {
5795 if (!_enabled) {
5796 return;
5797 }
5798
5799 var nativeEventTarget = getEventTarget(nativeEvent);
5800 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5801 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5802 // If we get an event (ex: img onload) before committing that
5803 // component's mount, ignore it for now (that is, treat it as if it was an
5804 // event on a non-React tree). We might also consider queueing events and
5805 // dispatching them after the mount.
5806 targetInst = null;
5807 }
5808
5809 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5810
5811 try {
5812 // Event queue being processed in the same cycle allows
5813 // `preventDefault`.
5814 batchedUpdates(handleTopLevel, bookKeeping);
5815 } finally {
5816 releaseTopLevelCallbackBookKeeping(bookKeeping);
5817 }
5818}
5819
5820var ReactDOMEventListener = Object.freeze({
5821 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