mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Native view manager event types exposed to JS via view config
Differential Revision: D5814210 fbshipit-source-id: 41291f0d6b39af77f66173f6a699d88f9f4ccc74
This commit is contained in:
committed by
Facebook Github Bot
parent
e9780bdc0f
commit
75c94a8907
@@ -1446,6 +1446,11 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
[_componentDataByName enumerateKeysAndObjectsUsingBlock:^(NSString *name, RCTComponentData *componentData, __unused BOOL *stop) {
|
||||
NSMutableDictionary<NSString *, id> *moduleConstants = [NSMutableDictionary new];
|
||||
|
||||
// Register which event-types this view dispatches.
|
||||
// React needs this for the event plugin.
|
||||
NSMutableDictionary<NSString *, NSDictionary *> *bubblingEventTypes = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, NSDictionary *> *directEventTypes = [NSMutableDictionary new];
|
||||
|
||||
// Add manager class
|
||||
moduleConstants[@"Manager"] = RCTBridgeModuleNameForClass(componentData.managerClass);
|
||||
|
||||
@@ -1453,6 +1458,8 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
NSDictionary<NSString *, id> *viewConfig = [componentData viewConfig];
|
||||
moduleConstants[@"NativeProps"] = viewConfig[@"propTypes"];
|
||||
moduleConstants[@"baseModuleName"] = viewConfig[@"baseModuleName"];
|
||||
moduleConstants[@"bubblingEventTypes"] = bubblingEventTypes;
|
||||
moduleConstants[@"directEventTypes"] = directEventTypes;
|
||||
|
||||
// Add direct events
|
||||
for (NSString *eventName in viewConfig[@"directEvents"]) {
|
||||
@@ -1461,6 +1468,7 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
@"registrationName": [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"],
|
||||
};
|
||||
}
|
||||
directEventTypes[eventName] = directEvents[eventName];
|
||||
if (RCT_DEBUG && bubblingEvents[eventName]) {
|
||||
RCTLogError(@"Component '%@' re-registered bubbling event '%@' as a "
|
||||
"direct event", componentData.name, eventName);
|
||||
@@ -1478,6 +1486,7 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
}
|
||||
};
|
||||
}
|
||||
bubblingEventTypes[eventName] = bubblingEvents[eventName];
|
||||
if (RCT_DEBUG && directEvents[eventName]) {
|
||||
RCTLogError(@"Component '%@' re-registered direct event '%@' as a "
|
||||
"bubbling event", componentData.name, eventName);
|
||||
@@ -1488,9 +1497,6 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
constants[name] = moduleConstants;
|
||||
}];
|
||||
|
||||
constants[@"customBubblingEventTypes"] = bubblingEvents;
|
||||
constants[@"customDirectEventTypes"] = directEvents;
|
||||
|
||||
return constants;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user