@samitouri / QOS-React / commits / 64e1921aab

Fix Flow type that event target can be null (#13124)

We pass null sometimes when the event target has disappeared. E.g. when touches fires on a deleted node.

Sebastian Markbåge committed Jun 29, 2018 at 12:51 UTC 64e1921aab4f7ad7e2f345f392033ffe724e52e9
6 files changed +9 -9
packages/events/EventPluginHub.js
+2 -2
@@ -167,7 +167,7 @@ export function getListener(inst: Fiber, registrationName: string) {
167 */
168 function extractEvents(
169 topLevelType: TopLevelType,
170 - targetInst: Fiber,
170 + targetInst: null | Fiber,
171 nativeEvent: AnyNativeEvent,
172 nativeEventTarget: EventTarget,
173 ): Array<ReactSyntheticEvent> | ReactSyntheticEvent | null {
@@ -229,7 +229,7 @@ export function runEventsInBatch(
229
230 export function runExtractedEventsInBatch(
231 topLevelType: TopLevelType,
232 - targetInst: Fiber,
232 + targetInst: null | Fiber,
233 nativeEvent: AnyNativeEvent,
234 nativeEventTarget: EventTarget,
235 ) {
packages/events/PluginModuleType.js
+1 -1
@@ -24,7 +24,7 @@ export type PluginModule<NativeEvent> = {
24 eventTypes: EventTypes,
25 extractEvents: (
26 topLevelType: TopLevelType,
27 - targetInst: Fiber,
27 + targetInst: null | Fiber,
28 nativeTarget: NativeEvent,
29 nativeEventTarget: EventTarget,
30 ) => ?ReactSyntheticEvent,
packages/react-dom/src/events/SimpleEventPlugin.js
+1 -1
@@ -212,7 +212,7 @@ const SimpleEventPlugin: PluginModule<MouseEvent> & {
212
213 extractEvents: function(
214 topLevelType: TopLevelType,
215 - targetInst: Fiber,
215 + targetInst: null | Fiber,
216 nativeEvent: MouseEvent,
217 nativeEventTarget: EventTarget,
218 ): null | ReactSyntheticEvent {
packages/react-native-renderer/src/ReactFabricEventEmitter.js
+2 -2
@@ -19,11 +19,11 @@ import type {TopLevelType} from 'events/TopLevelEventTypes';
19 export {getListener, registrationNameModules as registrationNames};
20
21 export function dispatchEvent(
22 - target: Object,
22 + target: null | Object,
23 topLevelType: TopLevelType,
24 nativeEvent: AnyNativeEvent,
25 ) {
26 - const targetFiber = (target: Fiber);
26 + const targetFiber = (target: null | Fiber);
27 batchedUpdates(function() {
28 runExtractedEventsInBatch(
29 topLevelType,
packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js
+1 -1
@@ -31,7 +31,7 @@ const ReactNativeBridgeEventPlugin = {
31 */
32 extractEvents: function(
33 topLevelType: TopLevelType,
34 - targetInst: Object,
34 + targetInst: null | Object,
35 nativeEvent: AnyNativeEvent,
36 nativeEventTarget: Object,
37 ): ?Object {
scripts/flow/react-native-host-hooks.js
+2 -2
@@ -100,7 +100,7 @@ declare module 'FabricUIManager' {
100 viewName: string,
101 rootTag: number,
102 props: ?Object,
103 - instanceHandle: Object,
103 + eventTarget: Object,
104 ): Object;
105 declare function cloneNode(node: Object, instanceHandle: Object): Object;
106 declare function cloneNodeWithNewChildren(
@@ -124,7 +124,7 @@ declare module 'FabricUIManager' {
124 declare function completeRoot(rootTag: number, childSet: Object): void;
125 declare function registerEventHandler(
126 callback: (
127 - instanceHandle: Object,
127 + eventTarget: null | Object,
128 type: RNTopLevelEventType,
129 payload: Object,
130 ) => void,