Skip to content

Commit

Permalink
Immediately trigger renderApplication from RCTRootView init
Browse files Browse the repository at this point in the history
Reviewed By: fkgozali

Differential Revision: D4849610

fbshipit-source-id: 291a9bcdf0efe47d83130fe2675f3ef04a3f085b
  • Loading branch information
javache authored and facebook-github-bot committed Apr 21, 2017
1 parent 6138e20 commit 59378f7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ - (void)setUp
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"UIExplorerUnitTestsBundle" withExtension:@"js"]
moduleProvider:nil
launchOptions:nil];
RUN_RUNLOOP_WHILE(_bridge.isLoading);
}

- (void)testSetProps
Expand Down
6 changes: 4 additions & 2 deletions React/Base/RCTRootContentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

@interface RCTRootContentView : RCTView <RCTInvalidating>

@property (nonatomic, readonly) BOOL contentHasAppeared;
@property (nonatomic, readonly, weak) RCTBridge *bridge;
@property (nonatomic, readonly, assign) BOOL contentHasAppeared;
@property (nonatomic, readonly, strong) RCTTouchHandler *touchHandler;
@property (nonatomic, readonly, assign) CGSize availableSize;

@property (nonatomic, assign) BOOL passThroughTouches;
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility;
@property (nonatomic, readonly) CGSize availableSize;

- (instancetype)initWithFrame:(CGRect)frame
bridge:(RCTBridge *)bridge
Expand Down
1 change: 0 additions & 1 deletion React/Base/RCTRootContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

@implementation RCTRootContentView
{
__weak RCTBridge *_bridge;
UIColor *_backgroundColor;
}

Expand Down
12 changes: 7 additions & 5 deletions React/Base/RCTRootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
}
#endif

if (!_bridge.loading) {
[self bundleFinishedLoading:([_bridge batchedBridge] ?: _bridge)];
}

[self showLoadingView];

// Immediately schedule the application to be started
[self bundleFinishedLoading:[_bridge batchedBridge]];

This comment has been minimized.

Copy link
@zsading

zsading Jun 26, 2019

I have doubts about this change.Why does the loading value of the bridge no longer affect the application startup? @fkgozali

}

RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
Expand Down Expand Up @@ -259,11 +258,14 @@ - (void)javaScriptDidLoad:(NSNotification *)notification
// Use the (batched) bridge that's sent in the notification payload, so the
// RCTRootContentView is scoped to the right bridge
RCTBridge *bridge = notification.userInfo[@"bridge"];
[self bundleFinishedLoading:bridge];
if (bridge != _contentView.bridge) {
[self bundleFinishedLoading:bridge];
}
}

- (void)bundleFinishedLoading:(RCTBridge *)bridge
{
RCTAssert(bridge != nil, @"Bridge cannot be nil");
if (!bridge.valid) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ - (void)setNeedsLayout
{
// If there is an active batch layout will happen when batch finished, so we will wait for that.
// Otherwise we immidiately trigger layout.
if (![_bridge isBatchActive]) {
if (![_bridge isBatchActive] && ![_bridge isLoading]) {
[self _layoutAndMount];
}
}
Expand Down

0 comments on commit 59378f7

Please sign in to comment.