Skip to content

Commit 75eaff4

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
RCTReactNativeFactory remove RCTBridge methods and bridge property (facebook#57067)
Summary: Pull Request resolved: facebook#57067 Removes `RCTBridge`-related functions from `RCTReactNativeFactory` protocol and default delegate implementation as part of cleaning up legacy architecture APIs. Removes `createBridgeWithDelegate:launchOptions:`, `createRootViewWithBridge:moduleName:initProps:`, and the `bridge` property. The `bridgeAdapter` property is preserved as it returns `RCTSurfacePresenterBridgeAdapter`, not `RCTBridge`. Updates documentation in `RCTAppDelegate.h` to reflect the removed overridable methods. ## Changelog: [iOS][Breaking] Remove RCTBridge Functions from RCTReactNativeFactory Header Reviewed By: andrewdacenko Differential Revision: D107417684 fbshipit-source-id: 2f6f66a49502250c15c5c62d9abbbdfe10884d55
1 parent 6eb07a8 commit 75eaff4

7 files changed

Lines changed: 0 additions & 76 deletions

File tree

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#import "RCTReactNativeFactory.h"
1111
#import "RCTRootViewFactory.h"
1212

13-
@class RCTBridge;
1413
@protocol RCTBridgeDelegate;
1514
@protocol RCTComponentViewProtocol;
1615
@class RCTRootView;
@@ -41,10 +40,6 @@ NS_ASSUME_NONNULL_BEGIN
4140
*
4241
* Overridable methods
4342
* Shared:
44-
* - (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary
45-
*)launchOptions;
46-
* - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString*)moduleName initProps:(NSDictionary
47-
*)initProps;
4843
* - (UIViewController *)createRootViewController;
4944
* - (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
5045
* New Architecture:

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ - (UIViewController *)createRootViewController
3131
return [UIViewController new];
3232
}
3333

34-
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions
35-
{
36-
return [[RCTBridge alloc] initWithDelegate:delegate launchOptions:launchOptions];
37-
}
38-
3934
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController
4035
{
4136
rootViewController.view = rootView;
@@ -57,21 +52,6 @@ - (void)customizeRootView:(RCTRootView *)rootView
5752
// Override point for customization after application launch.
5853
}
5954

60-
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
61-
moduleName:(NSString *)moduleName
62-
initProps:(NSDictionary *)initProps
63-
{
64-
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, YES);
65-
66-
#if TARGET_OS_TV
67-
rootView.backgroundColor = [UIColor clearColor];
68-
#else
69-
rootView.backgroundColor = [UIColor systemBackgroundColor];
70-
#endif
71-
72-
return rootView;
73-
}
74-
7555
- (RCTColorSpace)defaultColorSpace
7656
{
7757
return RCTColorSpaceSRGB;

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

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,6 @@ typedef NS_ENUM(NSInteger, RCTReleaseLevel) { Canary, Experimental, Stable };
4646
@property (nonatomic, strong) id<RCTDependencyProvider> dependencyProvider;
4747

4848
@optional
49-
/**
50-
* It creates a `RCTBridge` using a delegate and some launch options.
51-
* By default, it is invoked passing `self` as a delegate.
52-
* You can override this function to customize the logic that creates the RCTBridge
53-
*
54-
* @parameter: delegate - an object that implements the `RCTBridgeDelegate` protocol.
55-
* @parameter: launchOptions - a dictionary with a set of options.
56-
*
57-
* @returns: a newly created instance of RCTBridge.
58-
*/
59-
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate
60-
launchOptions:(NSDictionary *)launchOptions
61-
__attribute__((deprecated(
62-
"createBridgeWithDelegate:launchOptions: is deprecated and will be removed when removing the legacy architecture.")));
63-
64-
/**
65-
* It creates a `UIView` starting from a bridge, a module name and a set of initial properties.
66-
* By default, it is invoked using the bridge created by `createBridgeWithDelegate:launchOptions` and
67-
* the name in the `self.moduleName` variable.
68-
* You can override this function to customize the logic that creates the Root View.
69-
*
70-
* @parameter: bridge - an instance of the `RCTBridge` object.
71-
* @parameter: moduleName - the name of the app, used by Metro to resolve the module.
72-
* @parameter: initProps - a set of initial properties.
73-
*
74-
* @returns: a UIView properly configured with a bridge for React Native.
75-
*/
76-
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
77-
moduleName:(NSString *)moduleName
78-
initProps:(NSDictionary *)initProps
79-
__attribute__((deprecated(
80-
"createRootViewWithBridge:moduleName:initProps is deprecated and will be removed when removing the legacy architecture.")));
81-
8249
/// This method returns a map of Component Descriptors and Components classes that needs to be registered in the
8350
/// new renderer. The Component Descriptor is a string which represent the name used in JS to refer to the native
8451
/// component. The default implementation returns an empty dictionary. Subclasses can override this method to register
@@ -107,8 +74,6 @@ typedef NS_ENUM(NSInteger, RCTReleaseLevel) { Canary, Experimental, Stable };
10774
launchOptions:(NSDictionary *_Nullable)launchOptions;
10875

10976
#if !defined(RCT_REMOVE_LEGACY_ARCH)
110-
@property (nonatomic, nullable) RCTBridge *bridge
111-
__attribute__((deprecated("The bridge is deprecated and will be removed when removing the legacy architecture.")));
11277
@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter __attribute__((
11378
deprecated("The bridgeAdapter is deprecated and will be removed when removing the legacy architecture.")));
11479
#endif

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,6 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
238238
turboModuleEnabled:YES
239239
bridgelessEnabled:YES];
240240

241-
configuration.createRootViewWithBridge = ^UIView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps) {
242-
return [weakSelf.delegate createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
243-
};
244-
245-
configuration.createBridgeWithDelegate = ^RCTBridge *(id<RCTBridgeDelegate> delegate, NSDictionary *launchOptions) {
246-
return [weakSelf.delegate createBridgeWithDelegate:delegate launchOptions:launchOptions];
247-
};
248-
249241
configuration.customizeRootView = ^(UIView *_Nonnull rootView) {
250242
[weakSelf.delegate customizeRootView:(RCTRootView *)rootView];
251243
};

scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,6 @@ interface RCTRadialGradient : public NSObject {
15831583
}
15841584

15851585
interface RCTReactNativeFactory : public NSObject {
1586-
public @property (assign) RCTBridge* bridge;
15871586
public @property (assign) RCTDevMenuConfiguration* devMenuConfiguration;
15881587
public @property (assign) RCTSurfacePresenterBridgeAdapter* bridgeAdapter;
15891588
public @property (strong) RCTBundleConfiguration* bundleConfiguration;
@@ -2980,8 +2979,6 @@ protocol RCTReactNativeFactoryDelegate : public RCTBridgeDelegate, public RCTUIC
29802979
public @property (strong) id<RCTDependencyProvider> dependencyProvider;
29812980
public virtual NSDictionary<NSString*, Class<RCTComponentViewProtocol>>* thirdPartyFabricComponents();
29822981
public virtual NSURL* _Nullable bundleURL();
2983-
public virtual RCTBridge* createBridgeWithDelegate:launchOptions:(id<RCTBridgeDelegate> delegate, NSDictionary* launchOptions);
2984-
public virtual UIView* createRootViewWithBridge:moduleName:initProps:(RCTBridge* bridge, NSString* moduleName, NSDictionary* initProps);
29852982
}
29862983

29872984
protocol RCTRedBoxExtraDataActionDelegate : public NSObject {

scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,8 +2967,6 @@ protocol RCTReactNativeFactoryDelegate : public RCTBridgeDelegate, public RCTUIC
29672967
public @property (strong) id<RCTDependencyProvider> dependencyProvider;
29682968
public virtual NSDictionary<NSString*, Class<RCTComponentViewProtocol>>* thirdPartyFabricComponents();
29692969
public virtual NSURL* _Nullable bundleURL();
2970-
public virtual RCTBridge* createBridgeWithDelegate:launchOptions:(id<RCTBridgeDelegate> delegate, NSDictionary* launchOptions);
2971-
public virtual UIView* createRootViewWithBridge:moduleName:initProps:(RCTBridge* bridge, NSString* moduleName, NSDictionary* initProps);
29722970
}
29732971

29742972
protocol RCTRedBoxExtraDataActionDelegate : public NSObject {

scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,6 @@ interface RCTRadialGradient : public NSObject {
15831583
}
15841584

15851585
interface RCTReactNativeFactory : public NSObject {
1586-
public @property (assign) RCTBridge* bridge;
15871586
public @property (assign) RCTDevMenuConfiguration* devMenuConfiguration;
15881587
public @property (assign) RCTSurfacePresenterBridgeAdapter* bridgeAdapter;
15891588
public @property (strong) RCTBundleConfiguration* bundleConfiguration;
@@ -2980,8 +2979,6 @@ protocol RCTReactNativeFactoryDelegate : public RCTBridgeDelegate, public RCTUIC
29802979
public @property (strong) id<RCTDependencyProvider> dependencyProvider;
29812980
public virtual NSDictionary<NSString*, Class<RCTComponentViewProtocol>>* thirdPartyFabricComponents();
29822981
public virtual NSURL* _Nullable bundleURL();
2983-
public virtual RCTBridge* createBridgeWithDelegate:launchOptions:(id<RCTBridgeDelegate> delegate, NSDictionary* launchOptions);
2984-
public virtual UIView* createRootViewWithBridge:moduleName:initProps:(RCTBridge* bridge, NSString* moduleName, NSDictionary* initProps);
29852982
}
29862983

29872984
protocol RCTRedBoxExtraDataActionDelegate : public NSObject {

0 commit comments

Comments
 (0)