fixed crash when setting custom shadow props to null
Reviewed By: emilsjolander Differential Revision: D3923634 fbshipit-source-id: 005e316e70fa280960c796375b2e94f9967a089d
This commit is contained in:
parent
0a0dd30c6a
commit
cfae3e376d
|
@ -145,8 +145,14 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
// Check for custom setter
|
||||
if ([keyPath isEqualToString:@"__custom__"]) {
|
||||
|
||||
// Get custom setter
|
||||
SEL customSetter = NSSelectorFromString([NSString stringWithFormat:@"set_%@:for%@View:withDefaultView:", name, shadowView ? @"Shadow" : @""]);
|
||||
// Get custom setter. There is no default view in the shadow case, so the selector is different.
|
||||
NSString *selectorString;
|
||||
if (!shadowView) {
|
||||
selectorString = [NSString stringWithFormat:@"set_%@:for%@View:withDefaultView:", name, shadowView ? @"Shadow" : @""];
|
||||
} else {
|
||||
selectorString = [NSString stringWithFormat:@"set_%@:forShadowView:", name];
|
||||
}
|
||||
SEL customSetter = NSSelectorFromString(selectorString);
|
||||
|
||||
propBlock = ^(id<RCTComponent> view, id json) {
|
||||
RCTComponentData *strongSelf = weakSelf;
|
||||
|
@ -154,13 +160,19 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
return;
|
||||
}
|
||||
json = RCTNilIfNull(json);
|
||||
if (!json && !strongSelf->_defaultView) {
|
||||
// Only create default view if json is null
|
||||
strongSelf->_defaultView = [strongSelf createViewWithTag:nil];
|
||||
if (!shadowView) {
|
||||
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, view, strongSelf->_defaultView
|
||||
);
|
||||
} else {
|
||||
((void (*)(id, SEL, id, id))objc_msgSend)(
|
||||
strongSelf.manager, customSetter, json, view
|
||||
);
|
||||
}
|
||||
((void (*)(id, SEL, id, id, id))objc_msgSend)(
|
||||
strongSelf.manager, customSetter, json, view, strongSelf->_defaultView
|
||||
);
|
||||
};
|
||||
|
||||
} else {
|
||||
|
|
|
@ -126,10 +126,10 @@ RCT_REMAP_VIEW_PROPERTY(name, __custom__, type) \
|
|||
/**
|
||||
* This macro can be used when you need to provide custom logic for setting
|
||||
* shadow view properties. The macro should be followed by a method body, which can
|
||||
* refer to "json", "view" and "defaultView" to implement the required logic.
|
||||
* refer to "json" and "view".
|
||||
*/
|
||||
#define RCT_CUSTOM_SHADOW_PROPERTY(name, type, viewClass) \
|
||||
RCT_REMAP_SHADOW_PROPERTY(name, __custom__, type) \
|
||||
- (void)set_##name:(id)json forShadowView:(viewClass *)view withDefaultView:(viewClass *)defaultView
|
||||
- (void)set_##name:(id)json forShadowView:(viewClass *)view
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue