Skip to content

Commit 98dc7d6

Browse files
zhongwuzwmeta-codesync[bot]
authored andcommitted
Forward host:didInitializeRuntime: callback to user delegate (#57438)
Summary: `RCTReactNativeFactory` acts as `RCTHost`'s delegate but did not implement `host:didInitializeRuntime:`, causing the optional callback to never reach the user's `RCTReactNativeFactoryDelegate`. Add the missing forwarding method following the same pattern as `hostDidStart:` so the runtime reference is properly delivered to the user delegate. Fixes #57349. ## Changelog: [IOS] [FIXED] - Forward `host:didInitializeRuntime:` callback to user delegate in `RCTReactNativeFactory` Pull Request resolved: #57438 Test Plan: 1. Implement `host:didInitializeRuntime:` in a custom `RCTReactNativeFactoryDelegate` subclass (e.g. RNTester's `AppDelegate`) 2. Build and launch the app 3. Verify the callback is invoked and the `jsi::Runtime` reference is received 4. Confirm `hostDidStart:` continues to work as before NOTE: No automated test. This mirrors the existing hostDidStart: forwarding in the same RCTReactNativeFactory, which is also untested. host:didInitializeRuntime: is declared on RCTHostDelegate and inherited by RCTReactNativeFactoryDelegate under optional, and the respondsToSelector: guard makes it a no-op for delegates that don't implement it, so there's no logic to regress. No RCTReactNativeFactory delegate-forwarding test harness exists, so a test would be net-new iOS XCTest scaffolding disproportionate to a one-line forward. Reviewed By: cortinico Differential Revision: D113653288 Pulled By: fabriziocucci fbshipit-source-id: 082bb340cd9d61bc30a10c8a7730eca14f69088e
1 parent 433e79d commit 98dc7d6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ - (void)hostDidStart:(RCTHost *)host
212212
}
213213
}
214214

215+
- (void)host:(RCTHost *)host didInitializeRuntime:(facebook::jsi::Runtime &)runtime
216+
{
217+
if ([_delegate respondsToSelector:@selector(host:didInitializeRuntime:)]) {
218+
[_delegate host:host didInitializeRuntime:runtime];
219+
}
220+
}
221+
215222
- (NSArray<NSString *> *)unstableModulesRequiringMainQueueSetup
216223
{
217224
#if RN_DISABLE_OSS_PLUGIN_HEADER

0 commit comments

Comments
 (0)