Skip to content

Commit

Permalink
Fixed loading flicker on RCTRootView
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed May 27, 2015
1 parent a4442e4 commit 8d99226
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions React/Base/RCTRootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ @implementation RCTRootView
RCTBridge *_bridge;
NSString *_moduleName;
NSDictionary *_launchOptions;
UIColor *_backgroundColor;
RCTRootContentView *_contentView;
}

Expand Down Expand Up @@ -90,15 +89,10 @@ - (instancetype)initWithBundleURL:(NSURL *)bundleURL

- (void)setBackgroundColor:(UIColor *)backgroundColor
{
_backgroundColor = backgroundColor;
super.backgroundColor = backgroundColor;
_contentView.backgroundColor = backgroundColor;
}

- (UIColor *)backgroundColor
{
return _backgroundColor;
}

- (UIViewController *)backingViewController
{
return _backingViewController ?: [super backingViewController];
Expand Down Expand Up @@ -135,7 +129,7 @@ - (void)bundleFinishedLoading:(RCTBridge *)bridge
[_contentView removeFromSuperview];
_contentView = [[RCTRootContentView alloc] initWithFrame:self.bounds
bridge:bridge];
_contentView.backgroundColor = _backgroundColor;
_contentView.backgroundColor = self.backgroundColor;
[self addSubview:_contentView];

NSString *moduleName = _moduleName ?: @"";
Expand Down Expand Up @@ -184,6 +178,7 @@ @implementation RCTRootContentView
{
__weak RCTBridge *_bridge;
RCTTouchHandler *_touchHandler;
UIColor *_backgroundColor;
}

- (instancetype)initWithFrame:(CGRect)frame
Expand All @@ -193,6 +188,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_bridge = bridge;
[self setUp];
self.frame = frame;
self.layer.backgroundColor = NULL;
}
return self;
}
Expand All @@ -207,12 +203,17 @@ - (void)setFrame:(CGRect)frame

- (void)setBackgroundColor:(UIColor *)backgroundColor
{
super.backgroundColor = backgroundColor;
_backgroundColor = backgroundColor;
if (self.reactTag && _bridge.isValid) {
[_bridge.uiManager setBackgroundColor:backgroundColor forRootView:self];
}
}

- (UIColor *)backgroundColor
{
return _backgroundColor;
}

- (void)setUp
{
/**
Expand Down

0 comments on commit 8d99226

Please sign in to comment.