Allow RCTRootView to be initialized with a frame
Summary: If a root view is initialized with a bridge that is already loaded, then it immediately will initialize its content view with a zero size, which results in that content view's size being calculated according to its content instead of the size set on the root view after initialization. This would lead to a race condition where sometimes the content view has a smaller size than the root view. Changelog: [iOS][Added] - Allow RCTRootView to be initialized with a frame Reviewed By: PeteTheHeat Differential Revision: D27052637 fbshipit-source-id: 384ab3be27c92c0d84d34d49afb697882335d890
This commit is contained in:
Родитель
cbc3d90fd4
Коммит
00bc09c8f7
|
@ -50,9 +50,18 @@ extern
|
|||
/**
|
||||
* - Designated initializer -
|
||||
*/
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
bridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(nullable NSDictionary *)initialProperties NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* - Convenience initializer -
|
||||
* The frame will default to CGRectZero.
|
||||
*/
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(nullable NSDictionary *)initialProperties NS_DESIGNATED_INITIALIZER;
|
||||
initialProperties:(nullable NSDictionary *)initialProperties;
|
||||
|
||||
/**
|
||||
* - Convenience initializer -
|
||||
|
|
|
@ -44,9 +44,10 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
|
|||
CGSize _intrinsicContentSize;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
bridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
RCTAssert(bridge, @"A bridge instance is required to create an RCTRootView");
|
||||
|
@ -57,7 +58,7 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
|
|||
[bridge.performanceLogger markStartForTag:RCTPLTTI];
|
||||
}
|
||||
|
||||
if (self = [super initWithFrame:CGRectZero]) {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
_bridge = bridge;
|
||||
|
@ -95,6 +96,13 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
|
|||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
{
|
||||
return [self initWithFrame:CGRectZero bridge:bridge moduleName:moduleName initialProperties:initialProperties];
|
||||
}
|
||||
|
||||
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
|
|
Загрузка…
Ссылка в новой задаче