Fix background color glitch

Summary:Because the source of truth for backgroundColor is the shadow view, it's possible for the default RCTView backgroundColor to get overwritten by the current shadowView backgroundColor when the view is first created. This overridden value will then be used as the default whenever the background color is reset, which may not be be appropriate for other components that use RCTView.

This diff fixes the bug by ensuring that the view props (and therefore the default color) are set *before* the background color is propagated from the shadowView.

Reviewed By: furdei

Differential Revision: D3064128

fb-gh-sync-id: ac36007c094c7201a5c4fd93399dee4d3eb9a043
shipit-source-id: ac36007c094c7201a5c4fd93399dee4d3eb9a043
This commit is contained in:
Nick Lockwood 2016-03-17 09:39:42 -07:00 committed by Facebook Github Bot 4
parent a4b01aee51
commit 4c7c365623
1 changed files with 1 additions and 1 deletions

View File

@ -897,10 +897,10 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
UIView *view = [componentData createViewWithTag:reactTag];
if (view) {
[componentData setProps:props forView:view]; // Must be done before bgColor to prevent wrong default
if ([view respondsToSelector:@selector(setBackgroundColor:)]) {
((UIView *)view).backgroundColor = backgroundColor;
}
[componentData setProps:props forView:view];
if ([view respondsToSelector:@selector(reactBridgeDidFinishTransaction)]) {
[uiManager->_bridgeTransactionListeners addObject:view];
}