From e13913e670870d974aab726cdcf177e9a3028e62 Mon Sep 17 00:00:00 2001 From: Eapen George Date: Thu, 25 Jun 2026 11:17:33 -0700 Subject: [PATCH] Export RCTDidInitializeModuleNotificationModuleKey for the `module` userInfo key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Add `RCTDidInitializeModuleNotificationModuleKey` to `RCTConstants.h`/`.m` so observers of `RCTDidInitializeModuleNotification` can read the module out of `userInfo` via a named constant instead of the bare `@"module"` literal. Update the poster in `RCTTurboModuleManager.mm` to use the new symbol so producer and consumer share a single source of truth. This follows the existing naming convention in `RCTConstants.h` (`RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey`). Purely additive — no existing API affected. Changelog: [iOS][Added] - Export `RCTDidInitializeModuleNotificationModuleKey` constant for `RCTDidInitializeModuleNotification` userInfo Differential Revision: D109716080 --- packages/react-native/React/Base/RCTConstants.h | 1 + packages/react-native/React/Base/RCTConstants.m | 1 + .../core/platform/ios/ReactCommon/RCTTurboModuleManager.mm | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/react-native/React/Base/RCTConstants.h b/packages/react-native/React/Base/RCTConstants.h index 72bbb0f7b5ce..185f57f4881f 100644 --- a/packages/react-native/React/Base/RCTConstants.h +++ b/packages/react-native/React/Base/RCTConstants.h @@ -44,6 +44,7 @@ RCT_EXTERN NSString *const RCTJavaScriptDidFailToLoadNotification; * the `[bridge moduleForClass:]` method. */ RCT_EXTERN NSString *const RCTDidInitializeModuleNotification; +RCT_EXTERN NSString *const RCTDidInitializeModuleNotificationModuleKey; /* * W3C Pointer Events diff --git a/packages/react-native/React/Base/RCTConstants.m b/packages/react-native/React/Base/RCTConstants.m index eb90640789f6..3c2acc59c084 100644 --- a/packages/react-native/React/Base/RCTConstants.m +++ b/packages/react-native/React/Base/RCTConstants.m @@ -20,6 +20,7 @@ NSString *const RCTJavaScriptWillStartLoadingNotification = @"RCTJavaScriptWillStartLoadingNotification"; NSString *const RCTDidInitializeModuleNotification = @"RCTDidInitializeModuleNotification"; +NSString *const RCTDidInitializeModuleNotificationModuleKey = @"module"; NSString *const RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED = @"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"; diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm index 0078a1a826a3..c5368ea8842f 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm @@ -726,9 +726,10 @@ - (BOOL)_shouldCreateObjCModule:(Class)moduleClass * TODO(T41180176): Investigate whether we can delete this after TM * rollout. */ - [[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification - object:nil - userInfo:@{@"module" : module, @"bridge" : [NSNull null]}]; + [[NSNotificationCenter defaultCenter] + postNotificationName:RCTDidInitializeModuleNotification + object:nil + userInfo:@{RCTDidInitializeModuleNotificationModuleKey : module, @"bridge" : [NSNull null]}]; TurboModulePerfLogger::moduleCreateSetUpEnd(moduleName, moduleId);