Home / Function/ SyntheticEvent() — react Function Reference

SyntheticEvent() — react Function Reference

Architecture documentation for the SyntheticEvent() function in SyntheticEvent.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a239bd27_5f3a_5675_1ae9_280a089300cf["SyntheticEvent()"]
  a47c9419_7313_73d9_a24c_401cd8fd59b8["SyntheticEvent.js"]
  a239bd27_5f3a_5675_1ae9_280a089300cf -->|defined in| a47c9419_7313_73d9_a24c_401cd8fd59b8
  c8539b01_7ed9_a8da_76bc_c3f3b079df32["addEventPoolingTo()"]
  a239bd27_5f3a_5675_1ae9_280a089300cf -->|calls| c8539b01_7ed9_a8da_76bc_c3f3b079df32
  style a239bd27_5f3a_5675_1ae9_280a089300cf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-native-renderer/src/legacy-events/SyntheticEvent.js lines 61–113

function SyntheticEvent(
  dispatchConfig,
  targetInst,
  nativeEvent,
  nativeEventTarget,
) {
  if (__DEV__) {
    // these have a getter/setter for warnings
    delete this.nativeEvent;
    delete this.preventDefault;
    delete this.stopPropagation;
    delete this.isDefaultPrevented;
    delete this.isPropagationStopped;
  }

  this.dispatchConfig = dispatchConfig;
  this._targetInst = targetInst;
  this.nativeEvent = nativeEvent;
  this._dispatchListeners = null;
  this._dispatchInstances = null;

  const Interface = this.constructor.Interface;
  for (const propName in Interface) {
    if (!Interface.hasOwnProperty(propName)) {
      continue;
    }
    if (__DEV__) {
      delete this[propName]; // this has a getter/setter for warnings
    }
    const normalize = Interface[propName];
    if (normalize) {
      this[propName] = normalize(nativeEvent);
    } else {
      if (propName === 'target') {
        this.target = nativeEventTarget;
      } else {
        this[propName] = nativeEvent[propName];
      }
    }
  }

  const defaultPrevented =
    nativeEvent.defaultPrevented != null
      ? nativeEvent.defaultPrevented
      : nativeEvent.returnValue === false;
  if (defaultPrevented) {
    this.isDefaultPrevented = functionThatReturnsTrue;
  } else {
    this.isDefaultPrevented = functionThatReturnsFalse;
  }
  this.isPropagationStopped = functionThatReturnsFalse;
  return this;
}

Domain

Subdomains

Frequently Asked Questions

What does SyntheticEvent() do?
SyntheticEvent() is a function in the react codebase, defined in packages/react-native-renderer/src/legacy-events/SyntheticEvent.js.
Where is SyntheticEvent() defined?
SyntheticEvent() is defined in packages/react-native-renderer/src/legacy-events/SyntheticEvent.js at line 61.
What does SyntheticEvent() call?
SyntheticEvent() calls 1 function(s): addEventPoolingTo.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free