Revert D6641403: [RN] Refined -[RCTUIManager createView:]

Differential Revision: D6641403

fbshipit-source-id: f478810413aa49b44c060db898e7e8698bddb8e1
This commit is contained in:
Valentin Shergin 2018-01-09 22:24:24 -08:00 committed by Facebook Github Bot
parent b0319f3293
commit b9b7fabf98
1 changed files with 11 additions and 9 deletions

View File

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