MCPcopy
hub / github.com/callstack/react-native-testing-library / findEventHandler

Function findEventHandler

src/fire-event.ts:73–92  ·  view source on GitHub ↗
(
  instance: TestInstance,
  eventName: string,
  nearestTouchResponder?: TestInstance,
)

Source from the content-addressed store, hash-verified

71}
72
73function findEventHandler(
74 instance: TestInstance,
75 eventName: string,
76 nearestTouchResponder?: TestInstance,
77): EventHandler | null {
78 const touchResponder = isTouchResponder(instance) ? instance : nearestTouchResponder;
79
80 const handler =
81 getEventHandlerFromProps(instance.props, eventName, { loose: true }) ??
82 findEventHandlerFromFiber(instance.unstable_fiber, eventName);
83 if (handler && isEventEnabled(instance, eventName, touchResponder)) {
84 return handler;
85 }
86
87 if (instance.parent === null) {
88 return null;
89 }
90
91 return findEventHandler(instance.parent, eventName, touchResponder);
92}
93
94function findEventHandlerFromFiber(fiber: Fiber | null, eventName: string): EventHandler | null {
95 // Container fibers have memoizedProps set to null

Callers 1

fireEventFunction · 0.85

Calls 4

getEventHandlerFromPropsFunction · 0.90
isTouchResponderFunction · 0.85
isEventEnabledFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…