Skip to content

Commit

Permalink
setJSResponder in Fabric renderer (#13031)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jun 14, 2018
1 parent 051637d commit bc963f3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// Module provided by RN:
import UIManager from 'UIManager';

const ReactFabricGlobalResponderHandler = {
onChange: function(from: any, to: any, blockNativeResponder: boolean) {
if (to !== null) {
const tag = to.stateNode.canonical._nativeTag;
UIManager.setJSResponder(tag, blockNativeResponder);
} else {
UIManager.clearJSResponder();
}
},
};

export default ReactFabricGlobalResponderHandler;
6 changes: 6 additions & 0 deletions packages/react-native-renderer/src/ReactFabricInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ import './ReactNativeInjectionShared';

import * as ReactFabricComponentTree from './ReactFabricComponentTree';
import * as EventPluginUtils from 'events/EventPluginUtils';
import ReactFabricGlobalResponderHandler from './ReactFabricGlobalResponderHandler';
import ResponderEventPlugin from 'events/ResponderEventPlugin';

EventPluginUtils.injection.injectComponentTree(ReactFabricComponentTree);

ResponderEventPlugin.injection.injectGlobalResponderHandler(
ReactFabricGlobalResponderHandler,
);
6 changes: 6 additions & 0 deletions packages/react-native-renderer/src/ReactNativeInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import './ReactNativeInjectionShared';
import * as ReactNativeComponentTree from './ReactNativeComponentTree';
import * as EventPluginUtils from 'events/EventPluginUtils';
import * as ReactNativeEventEmitter from './ReactNativeEventEmitter';
import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
import ResponderEventPlugin from 'events/ResponderEventPlugin';

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

EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree);

ResponderEventPlugin.injection.injectGlobalResponderHandler(
ReactNativeGlobalResponderHandler,
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ import ResponderEventPlugin from 'events/ResponderEventPlugin';

import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';
import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';

/**
* Inject module for resolving DOM hierarchy and plugin ordering.
*/
EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder);

ResponderEventPlugin.injection.injectGlobalResponderHandler(
ReactNativeGlobalResponderHandler,
);

/**
* Some important event plugins included by default (without having to require
* them).
Expand Down

0 comments on commit bc963f3

Please sign in to comment.