diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index c5bcb308e02ffb..f80e59e25a4627 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -534,6 +534,12 @@ - (void)_initializeBridgeLocked:(std::shared_ptr)executorFact } - (NSArray *)registerModulesForClasses:(NSArray *)moduleClasses +{ + return [self _registerModulesForClasses:moduleClasses lazilyDiscovered:NO]; +} + +- (NSArray *)_registerModulesForClasses:(NSArray *)moduleClasses + lazilyDiscovered:(BOOL)lazilyDiscovered { RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTCxxBridge initModulesWithDispatchGroup:] autoexported moduleData", nil); @@ -549,7 +555,7 @@ - (void)_initializeBridgeLocked:(std::shared_ptr)executorFact // Check for module name collisions RCTModuleData *moduleData = _moduleDataByName[moduleName]; if (moduleData) { - if (moduleData.hasInstance) { + if (moduleData.hasInstance || lazilyDiscovered) { // Existing module was preregistered, so it takes precedence continue; } else if ([moduleClass new] == nil) { @@ -682,7 +688,7 @@ - (void)registerExtraLazyModules lazilyDiscovered:(BOOL)lazilyDiscovered { // Set up moduleData for automatically-exported modules - NSArray *moduleDataById = [self registerModulesForClasses:modules]; + NSArray *moduleDataById = [self _registerModulesForClasses:modules lazilyDiscovered:lazilyDiscovered]; if (lazilyDiscovered) { #if RCT_DEBUG