Permalink
Browse files

Generalize/refactor `-[RCTUIManager rootViewForReactTag:withCompletio…

…n:]`

Reviewed By: shergin

Differential Revision: D5419037

fbshipit-source-id: c5a6afc826fd7ae805601c0c7940b4294bd34ef8
  • Loading branch information...
Yu-w authored and facebook-github-bot committed Jul 15, 2017
1 parent 5701ae2 commit fac62072778da0a63597a9633c665c81d7ae4402
Showing with 2 additions and 27 deletions.
  1. +2 −27 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 @@ - (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView
}
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 @@ - (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView
});
}
- (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

0 comments on commit fac6207

Please sign in to comment.