diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 803d139b0..fdce48583 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -963,7 +963,7 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag // Gather blocks to be executed now that all view hierarchy manipulations have // been completed (note that these may still take place before layout has finished) for (RCTComponentData *componentData in _componentDataByName.allValues) { - RCTViewManagerUIBlock uiBlock = [componentData.manager uiBlockToAmendWithShadowViewRegistry:_shadowViewRegistry]; + RCTViewManagerUIBlock uiBlock = [componentData uiBlockToAmendWithShadowViewRegistry:_shadowViewRegistry]; [self addUIBlock:uiBlock]; } diff --git a/React/Views/RCTComponentData.h b/React/Views/RCTComponentData.h index 38b242602..596dcc839 100644 --- a/React/Views/RCTComponentData.h +++ b/React/Views/RCTComponentData.h @@ -11,10 +11,10 @@ #import "RCTComponent.h" #import "RCTDefines.h" +#import "RCTViewManager.h" @class RCTBridge; @class RCTShadowView; -@class RCTViewManager; @class UIView; @interface RCTComponentData : NSObject @@ -33,4 +33,6 @@ - (NSDictionary *)viewConfig; +- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary *)registry; + @end diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index 34f2742a6..d5d34f5f8 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -14,7 +14,6 @@ #import "RCTBridge.h" #import "RCTShadowView.h" #import "RCTUtils.h" -#import "RCTViewManager.h" #import "UIView+React.h" typedef void (^RCTPropBlock)(id view, id json); @@ -44,6 +43,7 @@ typedef void (^RCTPropBlock)(id view, id json); RCTShadowView *_defaultShadowView; NSMutableDictionary *_viewPropBlocks; NSMutableDictionary *_shadowPropBlocks; + BOOL _implementsUIBlockToAmendWithShadowViewRegistry; __weak RCTBridge *_bridge; } @@ -63,6 +63,14 @@ typedef void (^RCTPropBlock)(id view, id json); if ([_name hasSuffix:@"Manager"]) { _name = [_name substringToIndex:_name.length - @"Manager".length]; } + + _implementsUIBlockToAmendWithShadowViewRegistry = NO; + Class cls = _managerClass; + while (cls != [RCTViewManager class]) { + _implementsUIBlockToAmendWithShadowViewRegistry = _implementsUIBlockToAmendWithShadowViewRegistry || + RCTClassOverridesInstanceMethod(cls, @selector(uiBlockToAmendWithShadowViewRegistry:)); + cls = [cls superclass]; + } } return self; } @@ -412,4 +420,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) }; } +- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary *)registry +{ + if (_implementsUIBlockToAmendWithShadowViewRegistry) { + return [[self manager] uiBlockToAmendWithShadowViewRegistry:registry]; + } + return nil; +} + @end