Skip to content

Commit bc963f3

Browse files
authored
setJSResponder in Fabric renderer (facebook#13031)
1 parent 051637d commit bc963f3

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,11 @@ import './ReactNativeInjectionShared';
1111

1212
import * as ReactFabricComponentTree from './ReactFabricComponentTree';
1313
import * as EventPluginUtils from 'events/EventPluginUtils';
14+
import ReactFabricGlobalResponderHandler from './ReactFabricGlobalResponderHandler';
15+
import ResponderEventPlugin from 'events/ResponderEventPlugin';
1416

1517
EventPluginUtils.injection.injectComponentTree(ReactFabricComponentTree);
18+
19+
ResponderEventPlugin.injection.injectGlobalResponderHandler(
20+
ReactFabricGlobalResponderHandler,
21+
);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import './ReactNativeInjectionShared';
1212
import * as ReactNativeComponentTree from './ReactNativeComponentTree';
1313
import * as EventPluginUtils from 'events/EventPluginUtils';
1414
import * as ReactNativeEventEmitter from './ReactNativeEventEmitter';
15+
import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
16+
import ResponderEventPlugin from 'events/ResponderEventPlugin';
1517

1618
// Module provided by RN:
1719
import RCTEventEmitter from 'RCTEventEmitter';
@@ -22,3 +24,7 @@ import RCTEventEmitter from 'RCTEventEmitter';
2224
RCTEventEmitter.register(ReactNativeEventEmitter);
2325

2426
EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree);
27+
28+
ResponderEventPlugin.injection.injectGlobalResponderHandler(
29+
ReactNativeGlobalResponderHandler,
30+
);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,12 @@ import ResponderEventPlugin from 'events/ResponderEventPlugin';
2121

2222
import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
2323
import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';
24-
import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
2524

2625
/**
2726
* Inject module for resolving DOM hierarchy and plugin ordering.
2827
*/
2928
EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder);
3029

31-
ResponderEventPlugin.injection.injectGlobalResponderHandler(
32-
ReactNativeGlobalResponderHandler,
33-
);
34-
3530
/**
3631
* Some important event plugins included by default (without having to require
3732
* them).

0 commit comments

Comments
 (0)