diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm index e075d4d3642597..a08f4b716e1708 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm @@ -96,17 +96,25 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled) return [@[ [RCTGIFImageDecoder new] ] arrayByAddingObjectsFromArray:imageDataDecoder]; }]; } else if (moduleClass == RCTNetworking.class) { - return [[moduleClass alloc] - initWithHandlersProvider:^NSArray> *(RCTModuleRegistry *moduleRegistry) { + return [[moduleClass alloc] + initWithHandlersProvider:^NSArray> *(RCTModuleRegistry *moduleRegistry) { NSArray *URLRequestHandlerModules = - extractModuleConformingToProtocol(moduleRegistry, @protocol(RCTURLRequestHandler)); - return [@[ - [RCTHTTPRequestHandler new], - [RCTDataRequestHandler new], - [RCTFileRequestHandler new], - [moduleRegistry moduleForName:"BlobModule"], - ] arrayByAddingObjectsFromArray:URLRequestHandlerModules]; - }]; + extractModuleConformingToProtocol(moduleRegistry, @protocol(RCTURLRequestHandler)); + + id blobModule = [moduleRegistry moduleForName:"BlobModule"]; + + NSMutableArray *handlers = [NSMutableArray arrayWithCapacity:4]; + [handlers addObject:[RCTHTTPRequestHandler new]]; + [handlers addObject:[RCTDataRequestHandler new]]; + [handlers addObject:[RCTFileRequestHandler new]]; + + if (blobModule) { + [handlers addObject:blobModule]; + } + + [handlers addObjectsFromArray:URLRequestHandlerModules]; + return handlers; + }]; } // No custom initializer here. return [moduleClass new];