Skip to content

Commit

Permalink
Support for inherited events in view managers
Browse files Browse the repository at this point in the history
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 <TextInput>s and avoid code duplication.

Reviewed By: sahrens

Differential Revision: D6690281

fbshipit-source-id: f142828bd7deae92fb306914b7cefd10da8b43f7
  • Loading branch information
shergin authored and facebook-github-bot committed Jan 12, 2018
1 parent d5e3f08 commit 2afe7d4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Libraries/ReactNative/requireNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 2afe7d4

Please sign in to comment.