From fac62072778da0a63597a9633c665c81d7ae4402 Mon Sep 17 00:00:00 2001 From: Yu Wang Date: Fri, 14 Jul 2017 18:14:50 -0700 Subject: [PATCH] Generalize/refactor `-[RCTUIManager rootViewForReactTag:withCompletion:]` Reviewed By: shergin Differential Revision: D5419037 fbshipit-source-id: c5a6afc826fd7ae805601c0c7940b4294bd34ef8 --- React/Modules/RCTUIManager.m | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index ae0f4f6ef..9ebbe10e1 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -33,6 +33,7 @@ #import "RCTRootShadowView.h" #import "RCTRootViewInternal.h" #import "RCTScrollableProtocol.h" +#import "RCTShadowView+Hierarchy.h" #import "RCTShadowView.h" #import "RCTUIManagerObserverCoordinator.h" #import "RCTUtils.h" @@ -1462,7 +1463,7 @@ RCT_EXPORT_METHOD(configureNextLayoutAnimation:(NSDictionary *)config } dispatch_async(RCTGetUIManagerQueue(), ^{ - NSNumber *rootTag = [self _rootTagForReactTag:reactTag]; + NSNumber *rootTag = [self shadowViewForReactTag:reactTag].rootView.reactTag; dispatch_async(dispatch_get_main_queue(), ^{ UIView *rootView = nil; if (rootTag != nil) { @@ -1473,32 +1474,6 @@ RCT_EXPORT_METHOD(configureNextLayoutAnimation:(NSDictionary *)config }); } -- (NSNumber *)_rootTagForReactTag:(NSNumber *)reactTag -{ - RCTAssert(!RCTIsMainQueue(), @"Should be called on shadow queue"); - - if (reactTag == nil) { - return nil; - } - - if (RCTIsReactRootView(reactTag)) { - return reactTag; - } - - NSNumber *rootTag = nil; - RCTShadowView *shadowView = _shadowViewRegistry[reactTag]; - while (shadowView) { - RCTShadowView *parent = [shadowView reactSuperview]; - if (!parent && RCTIsReactRootView(shadowView.reactTag)) { - rootTag = shadowView.reactTag; - break; - } - shadowView = parent; - } - - return rootTag; -} - static UIView *_jsResponder; + (UIView *)JSResponder