react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Deprecate RCTHostRuntimeDelegate and merge into RCTHostDelegate

Open tsapeta opened this issue 1 month ago • 0 comments

Summary:

Currently, there are two delegate protocols related to the RCTHost class that Frameworks can use: RCTHostDelegate and RCTHostRuntimeDelegate. RCTHostDelegate is easy to set and use as RCTReactNativeFactory already conforms to it. However, using the RCTHostRuntimeDelegate is less convenient because it can only be set via the host's runtimeDelegate property. This requires access to the host instance first, which in turn means having to wait for hostDidStart (see how we currently do this in Expo: https://github.com/expo/expo/blob/cacd14059830c00971d90d39cf8aa9e67f5e6de1/packages/expo/ios/AppDelegates/ExpoReactNativeFactory.mm#L28-L36). Additionally it's not clear that hostDidStart is called before host:didInitializeRuntime, especially since both are called from different threads. Relying on this ordering feels unsafe to me. I'm proposing to merge RCTHostRuntimeDelegate into RCTHostDelegate as they effectively serve the same purpose.

As part of this change, I've deprecated RCTHostRuntimeDelegate and its method. It can be removed in 0.85 or 0.86, depending on which release allows breaking changes. Instead, I've added the same method (optional) to RCTHostDelegate.

All call sites and tests have been updated accordingly.

Changelog:

[IOS] [DEPRECATED] - Deprecate RCTHostRuntimeDelegate and merge into RCTHostDelegate

Test Plan:

  • Manually added host:didInitializeRuntime: to RCTReactNativeFactory and confirmed it gets called
  • Tested this change in Expo and our own factory
  • Native unit tests are passing (for both the deprecated and new method)

tsapeta avatar Dec 17 '25 10:12 tsapeta