@samitouri / QOS-React / commits / bc963f353d

setJSResponder in Fabric renderer (#13031)

Sebastian Markbåge committed Jun 13, 2018 at 17:03 UTC bc963f353dc23a6c84c4d2b4daa51a4fdb12a6bc
4 files changed +36 -5
packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js new
+24
@@ -0,0 +1,24 @@
1 +/**
2 + * Copyright (c) 2015-present, Facebook, Inc.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +// Module provided by RN:
11 +import UIManager from 'UIManager';
12 +
13 +const ReactFabricGlobalResponderHandler = {
14 + onChange: function(from: any, to: any, blockNativeResponder: boolean) {
15 + if (to !== null) {
16 + const tag = to.stateNode.canonical._nativeTag;
17 + UIManager.setJSResponder(tag, blockNativeResponder);
18 + } else {
19 + UIManager.clearJSResponder();
20 + }
21 + },
22 +};
23 +
24 +export default ReactFabricGlobalResponderHandler;
packages/react-native-renderer/src/ReactFabricInjection.js
+6
@@ -11,5 +11,11 @@ import './ReactNativeInjectionShared';
11
12 import * as ReactFabricComponentTree from './ReactFabricComponentTree';
13 import * as EventPluginUtils from 'events/EventPluginUtils';
14 +import ReactFabricGlobalResponderHandler from './ReactFabricGlobalResponderHandler';
15 +import ResponderEventPlugin from 'events/ResponderEventPlugin';
16
17 EventPluginUtils.injection.injectComponentTree(ReactFabricComponentTree);
18 +
19 +ResponderEventPlugin.injection.injectGlobalResponderHandler(
20 + ReactFabricGlobalResponderHandler,
21 +);
packages/react-native-renderer/src/ReactNativeInjection.js
+6
@@ -12,6 +12,8 @@ import './ReactNativeInjectionShared';
12 import * as ReactNativeComponentTree from './ReactNativeComponentTree';
13 import * as EventPluginUtils from 'events/EventPluginUtils';
14 import * as ReactNativeEventEmitter from './ReactNativeEventEmitter';
15 +import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
16 +import ResponderEventPlugin from 'events/ResponderEventPlugin';
17
18 // Module provided by RN:
19 import RCTEventEmitter from 'RCTEventEmitter';
@@ -22,3 +24,7 @@ import RCTEventEmitter from 'RCTEventEmitter';
24 RCTEventEmitter.register(ReactNativeEventEmitter);
25
26 EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree);
27 +
28 +ResponderEventPlugin.injection.injectGlobalResponderHandler(
29 + ReactNativeGlobalResponderHandler,
30 +);
packages/react-native-renderer/src/ReactNativeInjectionShared.js
-5
@@ -21,17 +21,12 @@ import ResponderEventPlugin from 'events/ResponderEventPlugin';
21
22 import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
23 import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';
24 -import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
24
25 /**
26 * Inject module for resolving DOM hierarchy and plugin ordering.
27 */
28 EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder);
29
31 -ResponderEventPlugin.injection.injectGlobalResponderHandler(
32 - ReactNativeGlobalResponderHandler,
33 -);
34 -
30 /**
31 * Some important event plugins included by default (without having to require
32 * them).