Skip to content

Commit

Permalink
Refined -[RCTUIManager createView:]
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Jan 8, 2018
1 parent c491b22 commit e46ea8c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -967,21 +967,19 @@ - (void)_manageChildren:(NSNumber *)containerTag

// 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) {
preliminaryCreatedView = [componentData createViewWithTag:reactTag];
});

[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
if (!preliminaryCreatedView) {
return;
}
UIView *view = [componentData createViewWithTag:reactTag];
if (view) {
uiManager->_viewRegistry[reactTag] = view;
}
});

[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
UIView *view = viewRegistry[reactTag];
[componentData setProps:props forView:view];
uiManager->_viewRegistry[reactTag] = preliminaryCreatedView;
[componentData setProps:props forView:preliminaryCreatedView];
}];

[self _shadowView:shadowView didReceiveUpdatedProps:[props allKeys]];
Expand Down

0 comments on commit e46ea8c

Please sign in to comment.