[fix] ResponderEventPlugin injection for tree-shaking bundler

Previously this depended on a side-effecting `import` statement which
would be removed under tree-shaking.
This commit is contained in:
Nicolas Gallagher
2018-05-18 18:13:30 -07:00
parent 4a45595b7a
commit 9e9b40f155
2 changed files with 9 additions and 7 deletions
@@ -7,12 +7,18 @@
* @noflow
*/
import '../../modules/injectResponderEventPlugin';
import AccessibilityUtil from '../../modules/AccessibilityUtil';
import createDOMProps from '../../modules/createDOMProps';
import normalizeNativeEvent from '../../modules/normalizeNativeEvent';
import React from 'react';
import ReactDOM from 'react-dom';
import ResponderEventPlugin from '../../modules/ResponderEventPlugin';
const { EventPluginHub } = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
EventPluginHub.injection.injectEventPluginsByName({
ResponderEventPlugin
});
/**
* Ensure event handlers receive an event of the expected shape. The 'button'
@@ -1,10 +1,8 @@
// based on https://github.com/facebook/react/pull/4303/files
import normalizeNativeEvent from '../normalizeNativeEvent';
import ReactDOM from 'react-dom';
import ReactDOMUnstableNativeDependencies from 'react-dom/unstable-native-dependencies';
const { EventPluginHub } = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
const { ResponderEventPlugin, ResponderTouchHistoryStore } = ReactDOMUnstableNativeDependencies;
const topMouseDown = 'topMouseDown';
@@ -78,6 +76,4 @@ ResponderEventPlugin.extractEvents = (topLevelType, targetInst, nativeEvent, nat
);
};
EventPluginHub.injection.injectEventPluginsByName({
ResponderEventPlugin
});
export default ResponderEventPlugin;