Skip to content

Commit 217ee52

Browse files
Eapen Georgemeta-codesync[bot]
authored andcommitted
Export RCTDidInitializeModuleNotificationModuleKey for the module userInfo key (#57341)
Summary: Pull Request resolved: #57341 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 Reviewed By: christophpurrer Differential Revision: D109716080 fbshipit-source-id: caca922d1ca66da98f3232e0c7365826c057094e
1 parent a54b04e commit 217ee52

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

packages/react-native/React/Base/RCTConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ RCT_EXTERN NSString *const RCTJavaScriptDidFailToLoadNotification;
4444
* the `[bridge moduleForClass:]` method.
4545
*/
4646
RCT_EXTERN NSString *const RCTDidInitializeModuleNotification;
47+
RCT_EXTERN NSString *const RCTDidInitializeModuleNotificationModuleKey;
4748

4849
/*
4950
* W3C Pointer Events

packages/react-native/React/Base/RCTConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
NSString *const RCTJavaScriptWillStartLoadingNotification = @"RCTJavaScriptWillStartLoadingNotification";
2121

2222
NSString *const RCTDidInitializeModuleNotification = @"RCTDidInitializeModuleNotification";
23+
NSString *const RCTDidInitializeModuleNotificationModuleKey = @"module";
2324

2425
NSString *const RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED =
2526
@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED";

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,10 @@ - (BOOL)_shouldCreateObjCModule:(Class)moduleClass
726726
* TODO(T41180176): Investigate whether we can delete this after TM
727727
* rollout.
728728
*/
729-
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification
730-
object:nil
731-
userInfo:@{@"module" : module, @"bridge" : [NSNull null]}];
729+
[[NSNotificationCenter defaultCenter]
730+
postNotificationName:RCTDidInitializeModuleNotification
731+
object:nil
732+
userInfo:@{RCTDidInitializeModuleNotificationModuleKey : module, @"bridge" : [NSNull null]}];
732733

733734
TurboModulePerfLogger::moduleCreateSetUpEnd(moduleName, moduleId);
734735

0 commit comments

Comments
 (0)