diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h index 9d91ebb73d..c4803845ad 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h @@ -79,6 +79,11 @@ NS_ASSUME_NONNULL_BEGIN - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask NS_REQUIRES_SUPER; - (void)prepareForRecycle NS_REQUIRES_SUPER; +/* + * This is a fragment of temporary workaround that we need only temporary and will get rid of soon. + */ +- (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN; + @end NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 22921328b0..48fed7a720 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -564,4 +564,9 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) return _eventEmitter; } +- (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN +{ + return RCTNSStringFromString([[self class] componentDescriptorProvider].name); +} + @end diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 7aeefbb57b..d40995bc30 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -1065,6 +1065,25 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag { RCTShadowView *shadowView = _shadowViewRegistry[reactTag]; RCTComponentData *componentData = _componentDataByName[shadowView.viewName]; + + // Achtung! Achtung! + // This is a remarkably hacky and ugly workaround. + // We need this only temporary for some testing. We need this hack until Fabric fully implements command-execution pipeline. + // This does not affect non-Fabric apps. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" + if (!componentData) { + __block UIView *view; + RCTUnsafeExecuteOnMainQueueSync(^{ + view = self->_viewRegistry[reactTag]; + }); + if ([view respondsToSelector:@selector(componentViewName_DO_NOT_USE_THIS_IS_BROKEN)]) { + NSString *name = [view performSelector:@selector(componentViewName_DO_NOT_USE_THIS_IS_BROKEN)]; + componentData = _componentDataByName[[NSString stringWithFormat:@"RCT%@", name]]; + } + } +#pragma clang diagnostic pop + Class managerClass = componentData.managerClass; RCTModuleData *moduleData = [_bridge moduleDataForName:RCTBridgeModuleNameForClass(managerClass)]; id method = moduleData.methods[commandID];