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

Function dispatchEvent

code/redux/public/app.js:6172–6196  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

6170}
6171
6172function dispatchEvent(topLevelType, nativeEvent) {
6173 if (!_enabled) {
6174 return;
6175 }
6176
6177 var nativeEventTarget = getEventTarget(nativeEvent);
6178 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
6179 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
6180 // If we get an event (ex: img onload) before committing that
6181 // component's mount, ignore it for now (that is, treat it as if it was an
6182 // event on a non-React tree). We might also consider queueing events and
6183 // dispatching them after the mount.
6184 targetInst = null;
6185 }
6186
6187 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
6188
6189 try {
6190 // Event queue being processed in the same cycle allows
6191 // `preventDefault`.
6192 batchedUpdates(handleTopLevel, bookKeeping);
6193 } finally {
6194 releaseTopLevelCallbackBookKeeping(bookKeeping);
6195 }
6196}
6197
6198var ReactDOMEventListener = Object.freeze({
6199 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