Refined -[RCTUIManager createView:]

Summary: Now we do not add newly created view to the registry at the preluminary step.

Reviewed By: mmmulani

Differential Revision: D6641403

fbshipit-source-id: c69077aaba871f3cdb3500c75e1efe07546e1b7f
This commit is contained in:
Valentin Shergin 2018-01-07 21:24:48 -08:00 committed by Facebook Github Bot
parent c491b22233
commit e46ea8c737
1 changed files with 10 additions and 12 deletions

View File

@ -967,21 +967,19 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
// Dispatch view creation directly to the main thread instead of adding to
// UIBlocks array. This way, it doesn't get deferred until after layout.
__weak RCTUIManager *weakManager = self;
__block UIView *preliminaryCreatedView;
RCTExecuteOnMainQueue(^{
RCTUIManager *uiManager = weakManager;
if (!uiManager) {
return;
}
UIView *view = [componentData createViewWithTag:reactTag];
if (view) {
uiManager->_viewRegistry[reactTag] = view;
}
preliminaryCreatedView = [componentData createViewWithTag:reactTag];
});
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
UIView *view = viewRegistry[reactTag];
[componentData setProps:props forView:view];
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
if (!preliminaryCreatedView) {
return;
}
uiManager->_viewRegistry[reactTag] = preliminaryCreatedView;
[componentData setProps:props forView:preliminaryCreatedView];
}];
[self _shadowView:shadowView didReceiveUpdatedProps:[props allKeys]];