Backed out changeset 322626be193e

Reviewed By: wutalman

Differential Revision: D6258856

fbshipit-source-id: 392dc91f87148c70817f13858a7fcd368f028b2d
This commit is contained in:
Omri Gindi
2017-11-07 04:34:41 -08:00
committed by Facebook Github Bot
parent 164591218f
commit a6465d1c17
3 changed files with 55 additions and 28 deletions

View File

@@ -12,7 +12,6 @@
*/
'use strict';
const Platform = require('Platform');
const ReactNativeBridgeEventPlugin = require('ReactNativeBridgeEventPlugin');
const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
const UIManager = require('UIManager');
@@ -48,18 +47,35 @@ const warning = require('fbjs/lib/warning');
*/
import type {ComponentInterface} from 'verifyPropTypes';
let hasAttachedDefaultEventTypes: boolean = false;
function requireNativeComponent(
viewName: string,
componentInterface?: ?ComponentInterface,
extraConfig?: ?{nativeOnly?: Object},
): React$ComponentType<any> | string {
function attachDefaultEventTypes(viewConfig) {
if (Platform.OS === 'android') {
// This is supported on Android platform only,
// as lazy view managers discovery is Android-specific.
viewConfig = merge(viewConfig, UIManager.getDefaultEventTypes());
function attachBubblingEventTypes(viewConfig) {
if (UIManager.genericBubblingEventTypes) {
viewConfig.bubblingEventTypes = merge(
viewConfig.bubblingEventTypes,
UIManager.genericBubblingEventTypes,
);
// As genericBubblingEventTypes do not change over time, and there's
// merge of all the events happening in Fiber, we need to pass
// genericBubblingEventTypes to Fiber only once. Therefore, we can delete
// it and forget about it.
delete UIManager.genericBubblingEventTypes;
}
}
function attachDirectEventTypes(viewConfig) {
if (UIManager.genericDirectEventTypes) {
viewConfig.directEventTypes = merge(
viewConfig.directEventTypes,
UIManager.genericDirectEventTypes,
);
// As genericDirectEventTypes do not change over time, and there's merge
// of all the events happening in Fiber, we need to pass genericDirectEventTypes
// to Fiber only once. Therefore, we can delete it and forget about it.
delete UIManager.genericDirectEventTypes;
}
}
@@ -168,10 +184,8 @@ function requireNativeComponent(
);
}
if (!hasAttachedDefaultEventTypes) {
attachDefaultEventTypes(viewConfig);
hasAttachedDefaultEventTypes = true;
}
attachBubblingEventTypes(viewConfig);
attachDirectEventTypes(viewConfig);
// Register this view's event types with the ReactNative renderer.
// This enables view managers to be initialized lazily, improving perf,