Skip to content

Commit 305bde2

Browse files
Remove bridge mode from RCTComponentData (#59264)
Summary: RCTComponentData always runs bridgeless, so delete the always-false isBridgeMode helper, merge the manager properties into one strong reference, and use the injected event dispatcher directly. Changelog: [Internal] Reviewed By: shwanton Differential Revision: D126575276
1 parent dfe92ac commit 305bde2

6 files changed

Lines changed: 10 additions & 27 deletions

File tree

‎packages/react-native/React/Views/RCTComponentData.h‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ NS_ASSUME_NONNULL_BEGIN
2222

2323
@property (nonatomic, readonly) Class managerClass;
2424
@property (nonatomic, copy, readonly) NSString *name;
25-
@property (nonatomic, weak, readonly) RCTViewManager *manager;
2625
/*
27-
* When running React Native with the bridge, view managers are retained by the
28-
* bridge. When running in bridgeless mode, allocate and retain view managers
29-
* in this class.
26+
* The view manager for this component. In bridgeless mode, view managers
27+
* are allocated and retained by this class.
3028
*/
31-
@property (nonatomic, strong, readonly) RCTViewManager *bridgelessViewManager;
29+
@property (nonatomic, strong, readonly, nullable) RCTViewManager *manager;
3230

3331
- (instancetype)initWithManagerClass:(Class)managerClass
3432
bridge:(RCTBridge *)bridge

‎packages/react-native/React/Views/RCTComponentData.mm‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ @implementation RCTComponentData {
4444
}
4545

4646
@synthesize manager = _manager;
47-
@synthesize bridgelessViewManager = _bridgelessViewManager;
4847

4948
- (instancetype)initWithManagerClass:(Class)managerClass
5049
bridge:(RCTBridge *)bridge
@@ -62,21 +61,12 @@ - (instancetype)initWithManagerClass:(Class)managerClass
6261
return self;
6362
}
6463

65-
- (BOOL)isBridgeMode
66-
{
67-
// If we are in bridge mode, the bridge is RCTBridge
68-
// If we are bridgeless, the bridge is RCTBridgeProxy
69-
return [_bridge isKindOfClass:[RCTBridge class]];
70-
}
71-
7264
- (RCTViewManager *)manager
7365
{
74-
if ((_manager == nullptr) && [self isBridgeMode]) {
66+
if (_manager == nullptr) {
7567
_manager = [_bridge moduleForClass:_managerClass];
76-
} else if ((_manager == nullptr) && (_bridgelessViewManager == nullptr)) {
77-
_bridgelessViewManager = [_bridge moduleForClass:_managerClass];
7868
}
79-
return (_manager != nullptr) ? _manager : _bridgelessViewManager;
69+
return _manager;
8070
}
8171

8272
RCT_NOT_IMPLEMENTED(-(instancetype)init)
@@ -272,8 +262,7 @@ - (RCTPropBlock)createPropBlock:(NSString *)name isShadowView:(BOOL)isShadowView
272262
type == NSSelectorFromString(@"RCTDirectEventBlock:") ||
273263
type == NSSelectorFromString(@"RCTCapturingEventBlock:")) {
274264
// Special case for event handlers
275-
setterBlock = createEventSetter(
276-
name, setter, self.eventInterceptor, [self isBridgeMode] ? _bridge.eventDispatcher : _eventDispatcher);
265+
setterBlock = createEventSetter(name, setter, self.eventInterceptor, _eventDispatcher);
277266
} else {
278267
// Ordinary property handlers
279268
NSMethodSignature *typeSignature = [[RCTConvert class] methodSignatureForSelector:type];

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ interface RCTComponentData : public NSObject {
805805
public @property (assign, readonly) Class managerClass;
806806
public @property (copy) void(^eventInterceptor)(NSString* eventName, NSDictionary* event, NSNumber* reactTag);
807807
public @property (copy, readonly) NSString* name;
808-
public @property (strong, readonly) RCTViewManager* bridgelessViewManager;
809-
public @property (weak, readonly) RCTViewManager* manager;
808+
public @property (strong, readonly) RCTViewManager* manager;
810809
public virtual NSDictionary<NSString*, id>* viewConfig();
811810
public virtual RCTShadowView* createShadowViewWithTag:(NSNumber* tag);
812811
public virtual UIView* createViewWithTag:rootTag:(_Nullable NSNumber* tag, _Nullable NSNumber* rootTag);

‎scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,7 @@ interface RCTComponentData : public NSObject {
814814
public @property (assign, readonly) Class managerClass;
815815
public @property (copy) void(^eventInterceptor)(NSString* eventName, NSDictionary* event, NSNumber* reactTag);
816816
public @property (copy, readonly) NSString* name;
817-
public @property (strong, readonly) RCTViewManager* bridgelessViewManager;
818-
public @property (weak, readonly) RCTViewManager* manager;
817+
public @property (strong, readonly) RCTViewManager* manager;
819818
public virtual NSDictionary<NSString*, id>* viewConfig();
820819
public virtual RCTShadowView* createShadowViewWithTag:(NSNumber* tag);
821820
public virtual UIView* createViewWithTag:rootTag:(_Nullable NSNumber* tag, _Nullable NSNumber* rootTag);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ interface RCTComponentData : public NSObject {
805805
public @property (assign, readonly) Class managerClass;
806806
public @property (copy) void(^eventInterceptor)(NSString* eventName, NSDictionary* event, NSNumber* reactTag);
807807
public @property (copy, readonly) NSString* name;
808-
public @property (strong, readonly) RCTViewManager* bridgelessViewManager;
809-
public @property (weak, readonly) RCTViewManager* manager;
808+
public @property (strong, readonly) RCTViewManager* manager;
810809
public virtual NSDictionary<NSString*, id>* viewConfig();
811810
public virtual RCTShadowView* createShadowViewWithTag:(NSNumber* tag);
812811
public virtual UIView* createViewWithTag:rootTag:(_Nullable NSNumber* tag, _Nullable NSNumber* rootTag);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ interface RCTComponentData : public NSObject {
805805
public @property (assign, readonly) Class managerClass;
806806
public @property (copy) void(^eventInterceptor)(NSString* eventName, NSDictionary* event, NSNumber* reactTag);
807807
public @property (copy, readonly) NSString* name;
808-
public @property (strong, readonly) RCTViewManager* bridgelessViewManager;
809-
public @property (weak, readonly) RCTViewManager* manager;
808+
public @property (strong, readonly) RCTViewManager* manager;
810809
public virtual NSDictionary<NSString*, id>* viewConfig();
811810
public virtual RCTShadowView* createShadowViewWithTag:(NSNumber* tag);
812811
public virtual UIView* createViewWithTag:rootTag:(_Nullable NSNumber* tag, _Nullable NSNumber* rootTag);

0 commit comments

Comments
 (0)