From f6f461593bf929aa5d3798fa277f8324ece36f0e Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 9 Feb 2024 05:29:10 -0800 Subject: [PATCH] Make [RCTBridge currentBridge] work also inBridgeless for backward compatibility. (#42940) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42940 We might have some libraries that goes through the interop layer that are using [RCTBridge currentBridge]. Although this is an API that we would like them not to use, that's the sad reality and if we don't want to force a migration on those libraries, we need to be backward compatible. This diff sets the `RCTBridgeProxy` as the `currentBridge` in case the app is running in BridgelessMode. This should make Bridgeless backward compatible. ## Changelog [iOS][Fixed] - Make [RCTBridge currentBridge] work in bridgeless mode Reviewed By: RSNara Differential Revision: D53575361 fbshipit-source-id: 179e440662b577954a577e8400e0ce0dc5b4d3ff --- .../react/runtime/platform/ios/ReactCommon/RCTInstance.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index 9aaef33e9afa89..5bcec41c63dabf 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -12,6 +12,7 @@ #import #import +#import #import #import #import @@ -263,6 +264,7 @@ - (void)_start [strongSelf registerSegmentWithId:segmentId path:path]; } }]; + [RCTBridge setCurrentBridge:(RCTBridge *)bridgeProxy]; // Set up TurboModules _turboModuleManager = [[RCTTurboModuleManager alloc]