Skip to content

Commit 139f2a1

Browse files
fix(react-native-host): 3rd party components on new arch 0.77+ (#3534)
1 parent 105fc4e commit 139f2a1

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

.changeset/twenty-dancers-tap.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rnx-kit/react-native-host": patch
3+
---
4+
5+
Fix third party components on new arch 0.77+

packages/react-native-host/cocoa/RNXBridgelessHeaders.h

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
#define USE_FEATURE_FLAGS
2222
#endif // __has_include(<react/featureflags/ReactNativeFeatureFlags.h>)
2323

24+
#if __has_include(<ReactCodegen/RCTThirdPartyComponentsProvider.h>)
25+
#define USE_CODEGEN_PROVIDER 1
26+
#import <ReactCodegen/RCTThirdPartyComponentsProvider.h>
27+
#import <React/RCTComponentViewFactory.h>
28+
#endif // __has_include(<ReactCodegen/RCTThirdPartyComponentsProvider.h>)
29+
2430
#if __has_include(<react/runtime/JSEngineInstance.h>)
2531
using SharedJSRuntimeFactory = std::shared_ptr<facebook::react::JSEngineInstance>;
2632
#else

packages/react-native-host/cocoa/ReactNativeHost.mm

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#import "ReactNativeHost.h"
22

3+
// clang-format off
34
#include "FollyConfig.h"
5+
// clang-format on
46

57
#import <React/RCTBridge.h>
68
#import <React/RCTBundleURLProvider.h>
@@ -27,6 +29,11 @@ @interface ReactNativeHost () <RCTCxxBridgeDelegate>
2729
#endif // USE_BRIDGELESS
2830
@end
2931

32+
#ifdef USE_CODEGEN_PROVIDER
33+
@interface ReactNativeHost () <RCTComponentViewFactoryComponentProvider>
34+
@end
35+
#endif // USE_CODEGEN_PROVIDER
36+
3037
@implementation ReactNativeHost {
3138
__weak id<RNXHostConfig> _config;
3239
NSDictionary *_launchOptions;
@@ -59,6 +66,11 @@ - (instancetype)initWithConfig:(id<RNXHostConfig>)config launchOptions:(NSDictio
5966
_hostReleaser = [[RNXHostReleaser alloc] initWithHost:self];
6067
}
6168

69+
#ifdef USE_CODEGEN_PROVIDER
70+
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider =
71+
self;
72+
#endif // USE_CODEGEN_PROVIDER
73+
6274
#ifdef USE_FEATURE_FLAGS
6375
if (self.isBridgelessEnabled) {
6476
facebook::react::ReactNativeFeatureFlags::override(
@@ -224,6 +236,15 @@ - (void)didCreateContextContainer:
224236

225237
#endif // USE_BRIDGELESS
226238

239+
// MARK: - RCTComponentViewFactoryComponentProvider details
240+
241+
#ifdef USE_CODEGEN_PROVIDER
242+
- (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
243+
{
244+
return [RCTThirdPartyComponentsProvider thirdPartyFabricComponents];
245+
}
246+
#endif // USE_CODEGEN_PROVIDER
247+
227248
// MARK: - Private
228249

229250
- (BOOL)isBridgelessEnabled
@@ -274,7 +295,7 @@ - (void)initializeReactHost
274295
#else
275296
return std::make_shared<facebook::react::RCTHermesInstance>(nullptr, false);
276297
#endif // USE_REACT_NATIVE_CONFIG
277-
#else // USE_HERMES
298+
#else // USE_HERMES
278299
return std::make_shared<facebook::react::RCTJscInstance>();
279300
#endif // USE_HERMES
280301
};

0 commit comments

Comments
 (0)