mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make sure to pass the BridgeProxy to view managers in the interop layer (#45329)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45329 Thanks to [#45232](https://github.com/facebook/react-native/issues/45232) we found a bug in the interop layer, where we were not passing the BridgeProxy in bridgeless mode to the view managers. This Change should fix that issue. ## Changelog: [iOS][Fixed] - Make sure to pass the RCTBridgeProxy to ViewManagers Reviewed By: dmytrorykun Differential Revision: D59468292 fbshipit-source-id: 00666be21385a735878eb567c4b8a0986c609c5f
This commit is contained in:
committed by
Blake Friedman
parent
7484e72210
commit
28d171993e
@@ -61,12 +61,20 @@ static SEL selectorForType(NSString *type)
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isBridgeMode
|
||||
{
|
||||
// If we are in bridge mode, the bridge is RCTBridge
|
||||
// If we are bridgeless, the bridge is RCTBridgeProxy
|
||||
return [_bridge isKindOfClass:[RCTBridge class]];
|
||||
}
|
||||
|
||||
- (RCTViewManager *)manager
|
||||
{
|
||||
if (!_manager && _bridge) {
|
||||
if (!_manager && [self isBridgeMode]) {
|
||||
_manager = [_bridge moduleForClass:_managerClass];
|
||||
} else if (!_manager && !_bridgelessViewManager) {
|
||||
_bridgelessViewManager = [_managerClass new];
|
||||
_bridgelessViewManager.bridge = _bridge;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification
|
||||
object:nil
|
||||
userInfo:@{@"module" : _bridgelessViewManager}];
|
||||
@@ -265,8 +273,8 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
type == NSSelectorFromString(@"RCTDirectEventBlock:") ||
|
||||
type == NSSelectorFromString(@"RCTCapturingEventBlock:")) {
|
||||
// Special case for event handlers
|
||||
setterBlock =
|
||||
createEventSetter(name, setter, self.eventInterceptor, _bridge ? _bridge.eventDispatcher : _eventDispatcher);
|
||||
setterBlock = createEventSetter(
|
||||
name, setter, self.eventInterceptor, [self isBridgeMode] ? _bridge.eventDispatcher : _eventDispatcher);
|
||||
} else {
|
||||
// Ordinary property handlers
|
||||
NSMethodSignature *typeSignature = [[RCTConvert class] methodSignatureForSelector:type];
|
||||
|
||||
+4
-3
@@ -125,9 +125,10 @@ static const std::shared_ptr<void> constructCoordinator(
|
||||
bridgeModuleDecorator = unwrapManagedObject(optionalModuleDecorator.value());
|
||||
}
|
||||
|
||||
RCTComponentData *componentData = [[RCTComponentData alloc] initWithManagerClass:viewManagerClass
|
||||
bridge:bridge
|
||||
eventDispatcher:eventDispatcher];
|
||||
RCTComponentData *componentData =
|
||||
[[RCTComponentData alloc] initWithManagerClass:viewManagerClass
|
||||
bridge:bridge != nil ? bridge : (RCTBridge *)bridgeProxy
|
||||
eventDispatcher:eventDispatcher];
|
||||
return wrapManagedObject([[RCTLegacyViewManagerInteropCoordinator alloc]
|
||||
initWithComponentData:componentData
|
||||
bridge:bridge
|
||||
|
||||
Reference in New Issue
Block a user