Skip to content

Commit 59378f7

Browse files
javachefacebook-github-bot
authored andcommitted
Immediately trigger renderApplication from RCTRootView init
Reviewed By: fkgozali Differential Revision: D4849610 fbshipit-source-id: 291a9bcdf0efe47d83130fe2675f3ef04a3f085b
1 parent 6138e20 commit 59378f7

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

Examples/UIExplorer/UIExplorerUnitTests/RCTComponentPropsTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ - (void)setUp
9999
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"UIExplorerUnitTestsBundle" withExtension:@"js"]
100100
moduleProvider:nil
101101
launchOptions:nil];
102+
RUN_RUNLOOP_WHILE(_bridge.isLoading);
102103
}
103104

104105
- (void)testSetProps

React/Base/RCTRootContentView.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
@interface RCTRootContentView : RCTView <RCTInvalidating>
2020

21-
@property (nonatomic, readonly) BOOL contentHasAppeared;
21+
@property (nonatomic, readonly, weak) RCTBridge *bridge;
22+
@property (nonatomic, readonly, assign) BOOL contentHasAppeared;
2223
@property (nonatomic, readonly, strong) RCTTouchHandler *touchHandler;
24+
@property (nonatomic, readonly, assign) CGSize availableSize;
25+
2326
@property (nonatomic, assign) BOOL passThroughTouches;
2427
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility;
25-
@property (nonatomic, readonly) CGSize availableSize;
2628

2729
- (instancetype)initWithFrame:(CGRect)frame
2830
bridge:(RCTBridge *)bridge

React/Base/RCTRootContentView.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
@implementation RCTRootContentView
2121
{
22-
__weak RCTBridge *_bridge;
2322
UIColor *_backgroundColor;
2423
}
2524

React/Base/RCTRootView.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
9292
}
9393
#endif
9494

95-
if (!_bridge.loading) {
96-
[self bundleFinishedLoading:([_bridge batchedBridge] ?: _bridge)];
97-
}
98-
9995
[self showLoadingView];
96+
97+
// Immediately schedule the application to be started
98+
[self bundleFinishedLoading:[_bridge batchedBridge]];
10099
}
101100

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

265266
- (void)bundleFinishedLoading:(RCTBridge *)bridge
266267
{
268+
RCTAssert(bridge != nil, @"Bridge cannot be nil");
267269
if (!bridge.valid) {
268270
return;
269271
}

React/Modules/RCTUIManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ - (void)setNeedsLayout
12071207
{
12081208
// If there is an active batch layout will happen when batch finished, so we will wait for that.
12091209
// Otherwise we immidiately trigger layout.
1210-
if (![_bridge isBatchActive]) {
1210+
if (![_bridge isBatchActive] && ![_bridge isLoading]) {
12111211
[self _layoutAndMount];
12121212
}
12131213
}

0 commit comments

Comments
 (0)