From 052d20058b56ad68aa1658dcf73f15d6869aba13 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Wed, 1 Nov 2023 11:24:57 -0700 Subject: [PATCH] mark init as designated initializer for RCTNetworking (#41252) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41252 Changelog: [Internal] let's add compile time guarantee that `RCTNetworking` must go thru `initWithDisabledObservation`. Reviewed By: cipolleschi Differential Revision: D50764524 fbshipit-source-id: fcc92411b26343bd5977dbfa1b2e95f0841e4ac8 --- packages/react-native/Libraries/Network/RCTNetworking.h | 2 ++ packages/react-native/Libraries/Network/RCTNetworking.mm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Network/RCTNetworking.h b/packages/react-native/Libraries/Network/RCTNetworking.h index fcc9fe81714..b4507aad334 100644 --- a/packages/react-native/Libraries/Network/RCTNetworking.h +++ b/packages/react-native/Libraries/Network/RCTNetworking.h @@ -28,6 +28,8 @@ @interface RCTNetworking : RCTEventEmitter +- (instancetype)init NS_DESIGNATED_INITIALIZER; + /** * Allows RCTNetworking instances to be initialized with handlers. * The handlers will be requested via the bridge's moduleForName method when required. diff --git a/packages/react-native/Libraries/Network/RCTNetworking.mm b/packages/react-native/Libraries/Network/RCTNetworking.mm index 7abc90d75c2..6e0884dc241 100644 --- a/packages/react-native/Libraries/Network/RCTNetworking.mm +++ b/packages/react-native/Libraries/Network/RCTNetworking.mm @@ -170,7 +170,7 @@ RCT_EXPORT_MODULE() - (instancetype)initWithHandlersProvider: (NSArray> * (^)(RCTModuleRegistry *moduleRegistry))getHandlers { - if (self = [super initWithDisabledObservation]) { + if (self = [self init]) { _handlersProvider = getHandlers; } return self;