mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Improve constant extraction from RCTNativeModule
Reviewed By: dcaspi Differential Revision: D4829671 fbshipit-source-id: 6b1cef1d31c7d8981c6f1e304d3742e885f8a83b
This commit is contained in:
committed by
Facebook Github Bot
parent
f3dfd616f4
commit
2336ac299c
@@ -42,23 +42,9 @@ std::vector<MethodDescriptor> RCTNativeModule::getMethods() {
|
||||
}
|
||||
|
||||
folly::dynamic RCTNativeModule::getConstants() {
|
||||
// TODO mhorowitz #10487027: This does unnecessary work since it
|
||||
// only needs constants. Think about refactoring RCTModuleData or
|
||||
// NativeModule to make this more natural.
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||
@"[RCTNativeModule getConstants] moduleData.config", nil);
|
||||
NSArray *config = m_moduleData.config;
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
if (!config || config == (id)kCFNull) {
|
||||
return nullptr;
|
||||
}
|
||||
id constants = config[1];
|
||||
if (![constants isKindOfClass:[NSDictionary class]]) {
|
||||
return nullptr;
|
||||
}
|
||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||
@"[RCTNativeModule getConstants] convert", nil);
|
||||
@"[RCTNativeModule getConstants] moduleData.exportedConstants", nil);
|
||||
NSDictionary *constants = m_moduleData.exportedConstants;
|
||||
folly::dynamic ret = [RCTConvert folly_dynamic:constants];
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user