Skip to content

Commit

Permalink
Remove injectComponentTree from unstable-native-dependencies, add Eve…
Browse files Browse the repository at this point in the history
…ntPluginHub (facebook#13598)

* Remove injectComponentTree from unstable-native-dependencies, add
EventPluginHub

injectComponentTree was exposed for react-native-web, but wasn't
actually being used by the project. They were using EventPluginHub
through ReactDOM's secret internals, but that was removed in facebook#13539

This removes the unused injectComponentTree export, refactors the
ResponderEventPlugin test so it doesn't depend on it, and also adds
EventPluginHub to the exports to unbreak react-native-web

* Re-export injectEventPluginsByName from ReactDOM internals
  • Loading branch information
aweary authored and jetoneza committed Jan 23, 2019
1 parent 35fdb49 commit fb2723d
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 194 deletions.
12 changes: 10 additions & 2 deletions packages/events/__tests__/ResponderEventPlugin-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@
const {HostComponent} = require('shared/ReactWorkTags');

let EventPluginHub;
let EventPluginUtils;
let ResponderEventPlugin;

const touch = function(nodeHandle, i) {
return {target: nodeHandle, identifier: i};
};

function injectComponentTree(ComponentTree) {
EventPluginUtils.setComponentTree(
ComponentTree.getFiberCurrentPropsFromNode,
ComponentTree.getInstanceFromNode,
ComponentTree.getNodeFromInstance,
);
}

/**
* @param {NodeHandle} nodeHandle @see NodeHandle. Handle of target.
* @param {Array<Touch>} touches All active touches.
Expand Down Expand Up @@ -395,8 +404,7 @@ describe('ResponderEventPlugin', () => {

const ReactDOMUnstableNativeDependencies = require('react-dom/unstable-native-dependencies');
EventPluginHub = require('events/EventPluginHub');
const injectComponentTree =
ReactDOMUnstableNativeDependencies.injectComponentTree;
EventPluginUtils = require('events/EventPluginUtils');
ResponderEventPlugin =
ReactDOMUnstableNativeDependencies.ResponderEventPlugin;

Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ const ReactDOM: Object = {
ReactDOMComponentTree.getInstanceFromNode,
ReactDOMComponentTree.getNodeFromInstance,
ReactDOMComponentTree.getFiberCurrentPropsFromNode,
EventPluginHub.injection.injectEventPluginsByName,
EventPluginRegistry.eventNameDispatchConfigs,
EventPropagators.accumulateTwoPhaseDispatches,
EventPropagators.accumulateDirectDispatches,
Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/test-utils/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const [
/* eslint-disable no-unused-vars */
getNodeFromInstance,
getFiberCurrentPropsFromNode,
injectEventPluginsByName,
/* eslint-enable no-unused-vars */
eventNameDispatchConfigs,
accumulateTwoPhaseDispatches,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,23 @@ import * as EventPluginUtils from 'events/EventPluginUtils';
import ResponderEventPlugin from 'events/ResponderEventPlugin';
import ResponderTouchHistoryStore from 'events/ResponderTouchHistoryStore';

// This is used by react-native-web.
export function injectComponentTree(ComponentTree) {
EventPluginUtils.setComponentTree(
ComponentTree.getFiberCurrentPropsFromNode,
ComponentTree.getInstanceFromNode,
ComponentTree.getNodeFromInstance,
);
}

export {ResponderEventPlugin, ResponderTouchHistoryStore};

// Inject react-dom's ComponentTree into this module.
// Keep in sync with ReactDOM.js and ReactTestUtils.js:
const [
getInstanceFromNode,
getNodeFromInstance,
getFiberCurrentPropsFromNode,
injectEventPluginsByName,
] = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;

EventPluginUtils.setComponentTree(
getFiberCurrentPropsFromNode,
getInstanceFromNode,
getNodeFromInstance,
);

export {
ResponderEventPlugin,
ResponderTouchHistoryStore,
injectEventPluginsByName,
};
Loading

0 comments on commit fb2723d

Please sign in to comment.