From 2afe7d4765ffc0d0c71d233211edd1d21972040e Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Thu, 11 Jan 2018 19:00:27 -0800 Subject: [PATCH] Support for inherited events in view managers Summary: We currently support inherited view props but not event handlers, this diff fixes it. This change will allow to unify set of supported events for single- and multli-line s and avoid code duplication. Reviewed By: sahrens Differential Revision: D6690281 fbshipit-source-id: f142828bd7deae92fb306914b7cefd10da8b43f7 --- .../ReactNative/requireNativeComponent.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Libraries/ReactNative/requireNativeComponent.js b/Libraries/ReactNative/requireNativeComponent.js index 03fff7e0b..763572dc0 100644 --- a/Libraries/ReactNative/requireNativeComponent.js +++ b/Libraries/ReactNative/requireNativeComponent.js @@ -133,18 +133,34 @@ function requireNativeComponent( } let baseModuleName = viewConfig.baseModuleName; - let nativeProps = {...viewConfig.NativeProps}; + let bubblingEventTypes = viewConfig.bubblingEventTypes; + let directEventTypes = viewConfig.directEventTypes; + let nativeProps = viewConfig.NativeProps; while (baseModuleName) { const baseModule = UIManager[baseModuleName]; if (!baseModule) { warning(false, 'Base module "%s" does not exist', baseModuleName); baseModuleName = null; } else { - nativeProps = {...nativeProps, ...baseModule.NativeProps}; + bubblingEventTypes = { + ...baseModule.bubblingEventTypes, + ...bubblingEventTypes, + }; + directEventTypes = { + ...baseModule.directEventTypes, + ...directEventTypes, + }; + nativeProps = { + ...baseModule.NativeProps, + ...nativeProps, + }; baseModuleName = baseModule.baseModuleName; } } + viewConfig.bubblingEventTypes = bubblingEventTypes; + viewConfig.directEventTypes = directEventTypes; + for (const key in nativeProps) { let useAttribute = false; const attribute = {};