Skip to content

Commit 0418c8a

Browse files
authored
[RN] Move new event dispatching pipeline to RN (#36266)
## Summary We found a bug in the logic in #36253 and we realized it's very inconvenient to iterate on the implementation when it's in this repository, as we're forced to then synchronize it to RN to test changes. This moves the entire implementation to RN for simplicity and also to simplify some clean ups in the future (like removing `top` prefixes from native event types). ## How did you test this change? The changes are gated. Will test e2e in RN.
1 parent 5682442 commit 0418c8a

File tree

5 files changed

+6
-642
lines changed

5 files changed

+6
-642
lines changed

packages/react-native-renderer/src/ReactFabricEventEmitter.js

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,13 @@ import {runEventsInBatch} from './legacy-events/EventBatching';
3030

3131
import {
3232
RawEventEmitter,
33-
ReactNativeViewConfigRegistry,
34-
dispatchTrustedEvent,
35-
setEventInitTimeStamp,
33+
dispatchNativeEvent,
3634
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
3735
import {getPublicInstance} from './ReactFiberConfigFabric';
38-
import LegacySyntheticEvent from './LegacySyntheticEvent';
39-
import {topLevelTypeToEventName} from './ReactNativeEventTypeMapping';
40-
import {processResponderEvent} from './ReactNativeResponder';
4136
import {enableNativeEventTargetEventDispatching} from './ReactNativeFeatureFlags';
4237

4338
export {getListener, registrationNameModules as registrationNames};
4439

45-
const {customBubblingEventTypes, customDirectEventTypes} =
46-
ReactNativeViewConfigRegistry;
47-
4840
/**
4941
* Allows registered plugins an opportunity to extract events from top-level
5042
* native browser events.
@@ -143,38 +135,8 @@ export function dispatchEvent(
143135
RawEventEmitter.emit('*', event);
144136

145137
if (enableNativeEventTargetEventDispatching()) {
146-
// Process responder events before normal event dispatch.
147-
// This handles touch negotiation (onStartShouldSetResponder, etc.)
148-
processResponderEvent(topLevelType, targetFiber, nativeEvent);
149-
150-
// New EventTarget-based dispatch path
151138
if (eventTarget != null) {
152-
const bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
153-
const directDispatchConfig = customDirectEventTypes[topLevelType];
154-
const bubbles = bubbleDispatchConfig != null;
155-
156-
// Skip events that are not registered in the view config
157-
if (bubbles || directDispatchConfig != null) {
158-
const eventName = topLevelTypeToEventName(topLevelType);
159-
const options = {
160-
bubbles,
161-
cancelable: true,
162-
};
163-
// Preserve the native event timestamp for backwards compatibility.
164-
// The legacy SyntheticEvent system used nativeEvent.timeStamp || nativeEvent.timestamp.
165-
const nativeTimestamp =
166-
nativeEvent.timeStamp ?? nativeEvent.timestamp;
167-
if (typeof nativeTimestamp === 'number') {
168-
setEventInitTimeStamp(options, nativeTimestamp);
169-
}
170-
const syntheticEvent = new LegacySyntheticEvent(
171-
eventName,
172-
options,
173-
nativeEvent,
174-
);
175-
// $FlowFixMe[incompatible-call]
176-
dispatchTrustedEvent(eventTarget, syntheticEvent);
177-
}
139+
dispatchNativeEvent(eventTarget, topLevelType, nativeEvent);
178140
}
179141
} else {
180142
// Heritage plugin event system

packages/react-native-renderer/src/ReactNativeEventTypeMapping.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)