Removed duplicate UIManager constants
Summary: public We were calling constantsToExport twice for every ViewManager, and including two copies of the values in __fbBatchedBridgeConfig. This diff removes the copy from UIManager and then puts it back on the JS side. Reviewed By: tadeuzagallo Differential Revision: D2665625 fb-gh-sync-id: 147ec4bfb404835e3875964476ba233d619c28aa
This commit is contained in:
parent
32c19c1994
commit
ca20d710fc
|
@ -67,6 +67,8 @@ class MessageQueue {
|
||||||
this._genModulesConfig(localModules),this._moduleTable, this._methodTable
|
this._genModulesConfig(localModules),this._moduleTable, this._methodTable
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._copyNativeComponentConstants(this.RemoteModules);
|
||||||
|
|
||||||
this._debugInfo = {};
|
this._debugInfo = {};
|
||||||
this._remoteModuleTable = {};
|
this._remoteModuleTable = {};
|
||||||
this._remoteMethodTable = {};
|
this._remoteMethodTable = {};
|
||||||
|
@ -185,6 +187,30 @@ class MessageQueue {
|
||||||
* Private helper methods
|
* Private helper methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the ViewManager constants into UIManager. This is only
|
||||||
|
* needed for iOS, which puts the constants in the ViewManager
|
||||||
|
* namespace instead of UIManager, unlike Android.
|
||||||
|
*/
|
||||||
|
_copyNativeComponentConstants(remoteModules) {
|
||||||
|
let UIManager = remoteModules.RCTUIManager;
|
||||||
|
UIManager && Object.keys(UIManager).forEach(viewName => {
|
||||||
|
let viewConfig = UIManager[viewName];
|
||||||
|
if (viewConfig.Manager) {
|
||||||
|
const viewManager = remoteModules[viewConfig.Manager];
|
||||||
|
viewManager && Object.keys(viewManager).forEach(key => {
|
||||||
|
const value = viewManager[key];
|
||||||
|
if (typeof value !== 'function') {
|
||||||
|
if (!viewConfig.Constants) {
|
||||||
|
viewConfig.Constants = {};
|
||||||
|
}
|
||||||
|
viewConfig.Constants[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the old, object-based module structure to the new
|
* Converts the old, object-based module structure to the new
|
||||||
* array-based structure. TODO (t8823865) Removed this
|
* array-based structure. TODO (t8823865) Removed this
|
||||||
|
|
|
@ -1197,14 +1197,8 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||||
NSMutableDictionary<NSString *, id> *constantsNamespace =
|
NSMutableDictionary<NSString *, id> *constantsNamespace =
|
||||||
[NSMutableDictionary dictionaryWithDictionary:allJSConstants[name]];
|
[NSMutableDictionary dictionaryWithDictionary:allJSConstants[name]];
|
||||||
|
|
||||||
// Add custom constants
|
// Add manager class
|
||||||
// TODO: should these be inherited?
|
constantsNamespace[@"Manager"] = RCTBridgeModuleNameForClass([manager class]);
|
||||||
NSDictionary<NSString *, id> *constants = RCTClassOverridesInstanceMethod([manager class], @selector(constantsToExport)) ? [manager constantsToExport] : nil;
|
|
||||||
if (constants.count) {
|
|
||||||
RCTAssert(constantsNamespace[@"Constants"] == nil , @"Cannot redefine Constants in namespace: %@", name);
|
|
||||||
// add an additional 'Constants' namespace for each class
|
|
||||||
constantsNamespace[@"Constants"] = constants;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add native props
|
// Add native props
|
||||||
NSDictionary<NSString *, id> *viewConfig = [componentData viewConfig];
|
NSDictionary<NSString *, id> *viewConfig = [componentData viewConfig];
|
||||||
|
|
Loading…
Reference in New Issue