From ded362af81d5a11662acb0c26cc987dde7d25a64 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Wed, 16 Mar 2016 07:56:25 -0700 Subject: [PATCH] Fixed bug in defaultView logic Summary: In my recent refactor to remove defaultViews, I added a check for null json values to determine if defaultView needed to be created. Unfortunately this was checking for nil instead of NSNull. Reviewed By: javache Differential Revision: D3058383 fb-gh-sync-id: 2a21dd0beb0302a94ed5379d39a102cde1316a9d shipit-source-id: 2a21dd0beb0302a94ed5379d39a102cde1316a9d --- React/Views/RCTComponentData.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index e182f896b..c9f985f49 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -88,7 +88,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) { RCTAssertMainThread(); - UIView *view = [_manager view]; + UIView *view = [self.manager view]; view.reactTag = tag; view.multipleTouchEnabled = YES; view.userInteractionEnabled = YES; // required for touch handling @@ -117,10 +117,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) SEL type = NULL; NSString *keyPath = nil; SEL selector = NSSelectorFromString([NSString stringWithFormat:@"propConfig%@_%@", shadowView ? @"Shadow" : @"", name]); - Class managerClass = [_manager class]; - if ([managerClass respondsToSelector:selector]) { + if ([_managerClass respondsToSelector:selector]) { NSArray *typeAndKeyPath = - ((NSArray *(*)(id, SEL))objc_msgSend)(managerClass, selector); + ((NSArray *(*)(id, SEL))objc_msgSend)(_managerClass, selector); type = RCTConvertSelectorForType(typeAndKeyPath[0]); keyPath = typeAndKeyPath.count > 1 ? typeAndKeyPath[1] : nil; } else { @@ -140,12 +139,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) if (!strongSelf) { return; } + json = RCTNilIfNull(json); if (!json && !strongSelf->_defaultView) { // Only create default view if json is null strongSelf->_defaultView = [strongSelf createViewWithTag:nil]; } ((void (*)(id, SEL, id, id, id))objc_msgSend)( - strongSelf.manager, customSetter, json == (id)kCFNull ? nil : json, view, strongSelf->_defaultView + strongSelf.manager, customSetter, json, view, strongSelf->_defaultView ); }; @@ -173,7 +173,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) type == NSSelectorFromString(@"RCTDirectEventBlock:")) { // Special case for event handlers - __weak RCTViewManager *weakManager = _manager; + __weak RCTViewManager *weakManager = self.manager; setterBlock = ^(id target, id json) { __weak id weakTarget = target; ((void (*)(id, SEL, id))objc_msgSend)(target, setter, [RCTConvert BOOL:json] ? ^(NSDictionary *body) { @@ -443,7 +443,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) }; } -- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary *)registry +- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary *)registry { if (_implementsUIBlockToAmendWithShadowViewRegistry) { return [[self manager] uiBlockToAmendWithShadowViewRegistry:registry];