[fabric] Forked ReactNativeInjection for Fabric and avoid RCTEventEmitter setup in Fabric (#12265)
Kevin Gozali committed
Feb 21, 2018 at 15:40 UTC
02f4e7a80b047862b7b321c6d93bdda4f5417264
4 files changed
+72
-37
packages/react-native-renderer/src/ReactFabric.js
+1
-1
@@ -10,7 +10,7 @@
10
import type {ReactNativeType} from './ReactNativeTypes';
11
import type {ReactNodeList} from 'shared/ReactTypes';
12
13
-import './ReactNativeInjection';
13
+import './ReactFabricInjection';
14
15
import * as ReactPortal from 'shared/ReactPortal';
16
import * as ReactGenericBatching from 'events/ReactGenericBatching';
packages/react-native-renderer/src/ReactFabricInjection.js
new
+23
@@ -0,0 +1,23 @@
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
+import './ReactNativeInjectionShared';
11
+
12
+// TODO: The event emitter registration is interfering with the existing
13
+// ReactNative renderer. So disable it for Fabric for now.
14
+
15
+// import * as ReactNativeEventEmitter from './ReactNativeEventEmitter';
16
+
17
+// Module provided by RN:
18
+// import RCTEventEmitter from 'RCTEventEmitter';
19
+
20
+/**
21
+ * Register the event emitter with the native bridge
22
+ */
23
+// RCTEventEmitter.register(ReactNativeEventEmitter);
packages/react-native-renderer/src/ReactNativeInjection.js
+3
-36
@@ -7,47 +7,14 @@
7
* @flow
8
*/
9
10
-/**
11
- * Make sure essential globals are available and are patched correctly. Please don't remove this
12
- * line. Bundles created by react-packager `require` it before executing any application code. This
13
- * ensures it exists in the dependency graph and can be `require`d.
14
- * TODO: require this in packager, not in React #10932517
15
- */
16
-// Module provided by RN:
17
-import 'InitializeCore';
10
+import './ReactNativeInjectionShared';
11
+
12
+import * as ReactNativeEventEmitter from './ReactNativeEventEmitter';
13
19
-import * as EventPluginHub from 'events/EventPluginHub';
20
-import * as EventPluginUtils from 'events/EventPluginUtils';
21
-import ResponderEventPlugin from 'events/ResponderEventPlugin';
14
// Module provided by RN:
15
import RCTEventEmitter from 'RCTEventEmitter';
16
25
-import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
26
-import * as ReactNativeComponentTree from './ReactNativeComponentTree';
27
-import * as ReactNativeEventEmitter from './ReactNativeEventEmitter';
28
-import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';
29
-import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
30
-
17
/**
18
* Register the event emitter with the native bridge
19
*/
20
RCTEventEmitter.register(ReactNativeEventEmitter);
35
-
36
-/**
37
- * Inject module for resolving DOM hierarchy and plugin ordering.
38
- */
39
-EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder);
40
-EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree);
41
-
42
-ResponderEventPlugin.injection.injectGlobalResponderHandler(
43
- ReactNativeGlobalResponderHandler,
44
-);
45
-
46
-/**
47
- * Some important event plugins included by default (without having to require
48
- * them).
49
- */
50
-EventPluginHub.injection.injectEventPluginsByName({
51
- ResponderEventPlugin: ResponderEventPlugin,
52
- ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin,
53
-});
packages/react-native-renderer/src/ReactNativeInjectionShared.js
new
+45
@@ -0,0 +1,45 @@
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
+/**
11
+ * Make sure essential globals are available and are patched correctly. Please don't remove this
12
+ * line. Bundles created by react-packager `require` it before executing any application code. This
13
+ * ensures it exists in the dependency graph and can be `require`d.
14
+ * TODO: require this in packager, not in React #10932517
15
+ */
16
+// Module provided by RN:
17
+import 'InitializeCore';
18
+
19
+import * as EventPluginHub from 'events/EventPluginHub';
20
+import * as EventPluginUtils from 'events/EventPluginUtils';
21
+import ResponderEventPlugin from 'events/ResponderEventPlugin';
22
+
23
+import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
24
+import * as ReactNativeComponentTree from './ReactNativeComponentTree';
25
+import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';
26
+import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler';
27
+
28
+/**
29
+ * Inject module for resolving DOM hierarchy and plugin ordering.
30
+ */
31
+EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder);
32
+EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree);
33
+
34
+ResponderEventPlugin.injection.injectGlobalResponderHandler(
35
+ ReactNativeGlobalResponderHandler,
36
+);
37
+
38
+/**
39
+ * Some important event plugins included by default (without having to require
40
+ * them).
41
+ */
42
+EventPluginHub.injection.injectEventPluginsByName({
43
+ ResponderEventPlugin: ResponderEventPlugin,
44
+ ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin,
45
+});