Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Fixed bug in defaultView logic
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicklockwood authored and Facebook Github Bot 3 committed Mar 16, 2016
1 parent 2273e01 commit ded362a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions React/Views/RCTComponentData.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ - (UIView *)createViewWithTag:(NSNumber *)tag
{
RCTAssertMainThread();

UIView *view = [_manager view];
UIView *view = [self.manager view];
view.reactTag = tag;
view.multipleTouchEnabled = YES;
view.userInteractionEnabled = YES; // required for touch handling
Expand Down Expand Up @@ -117,10 +117,9 @@ - (RCTPropBlock)propBlockForKey:(NSString *)name
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<NSString *> *typeAndKeyPath =
((NSArray<NSString *> *(*)(id, SEL))objc_msgSend)(managerClass, selector);
((NSArray<NSString *> *(*)(id, SEL))objc_msgSend)(_managerClass, selector);
type = RCTConvertSelectorForType(typeAndKeyPath[0]);
keyPath = typeAndKeyPath.count > 1 ? typeAndKeyPath[1] : nil;
} else {
Expand All @@ -140,12 +139,13 @@ - (RCTPropBlock)propBlockForKey:(NSString *)name
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
);
};

Expand Down Expand Up @@ -173,7 +173,7 @@ - (RCTPropBlock)propBlockForKey:(NSString *)name
type == NSSelectorFromString(@"RCTDirectEventBlock:")) {

// Special case for event handlers
__weak RCTViewManager *weakManager = _manager;
__weak RCTViewManager *weakManager = self.manager;
setterBlock = ^(id target, id json) {
__weak id<RCTComponent> weakTarget = target;
((void (*)(id, SEL, id))objc_msgSend)(target, setter, [RCTConvert BOOL:json] ? ^(NSDictionary *body) {
Expand Down Expand Up @@ -443,7 +443,7 @@ - (void)setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowV
};
}

- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNumber *,RCTShadowView *> *)registry
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNumber *, RCTShadowView *> *)registry
{
if (_implementsUIBlockToAmendWithShadowViewRegistry) {
return [[self manager] uiBlockToAmendWithShadowViewRegistry:registry];
Expand Down

0 comments on commit ded362a

Please sign in to comment.