Home / Function/ getListener() — react Function Reference

getListener() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  dc523599_fdf9_701c_242d_51dc12a7153c["getListener()"]
  090215d4_d041_d740_3c6a_2b92c717e601["getListener.js"]
  dc523599_fdf9_701c_242d_51dc12a7153c -->|defined in| 090215d4_d041_d740_3c6a_2b92c717e601
  ffe5dadd_1136_563b_f11c_19f1898c60be["accumulateSinglePhaseListeners()"]
  ffe5dadd_1136_563b_f11c_19f1898c60be -->|calls| dc523599_fdf9_701c_242d_51dc12a7153c
  dd9eb6ac_296c_ca63_51dd_da82f645aaaa["accumulateTwoPhaseListeners()"]
  dd9eb6ac_296c_ca63_51dd_da82f645aaaa -->|calls| dc523599_fdf9_701c_242d_51dc12a7153c
  c3b4d100_3a97_ec79_28bd_d0aeea38e3ff["shouldPreventMouseEvent()"]
  dc523599_fdf9_701c_242d_51dc12a7153c -->|calls| c3b4d100_3a97_ec79_28bd_d0aeea38e3ff
  style dc523599_fdf9_701c_242d_51dc12a7153c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/events/getListener.js lines 51–78

export default function getListener(
  inst: Fiber,
  registrationName: string,
): Function | null {
  const stateNode = inst.stateNode;
  if (stateNode === null) {
    // Work in progress (ex: onload events in incremental mode).
    return null;
  }
  const props = getFiberCurrentPropsFromNode(stateNode);
  if (props === null) {
    // Work in progress.
    return null;
  }
  // $FlowFixMe[invalid-computed-prop]
  const listener = props[registrationName];
  if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
    return null;
  }

  if (listener && typeof listener !== 'function') {
    throw new Error(
      `Expected \`${registrationName}\` listener to be a function, instead got a value of \`${typeof listener}\` type.`,
    );
  }

  return listener;
}

Domain

Subdomains

Frequently Asked Questions

What does getListener() do?
getListener() is a function in the react codebase, defined in packages/react-dom-bindings/src/events/getListener.js.
Where is getListener() defined?
getListener() is defined in packages/react-dom-bindings/src/events/getListener.js at line 51.
What does getListener() call?
getListener() calls 1 function(s): shouldPreventMouseEvent.
What calls getListener()?
getListener() is called by 2 function(s): accumulateSinglePhaseListeners, accumulateTwoPhaseListeners.

Analyze Your Own Codebase

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

Try Supermodel Free