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
|
// Check for custom setter
|
||||||
if ([keyPath isEqualToString:@"__custom__"]) {
|
if ([keyPath isEqualToString:@"__custom__"]) {
|
||||||
|
|
||||||
// Get custom setter
|
// Get custom setter. There is no default view in the shadow case, so the selector is different.
|
||||||
SEL customSetter = NSSelectorFromString([NSString stringWithFormat:@"set_%@:for%@View:withDefaultView:", name, shadowView ? @"Shadow" : @""]);
|
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) {
|
propBlock = ^(id<RCTComponent> view, id json) {
|
||||||
RCTComponentData *strongSelf = weakSelf;
|
RCTComponentData *strongSelf = weakSelf;
|
||||||
|
@ -154,6 +160,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
json = RCTNilIfNull(json);
|
json = RCTNilIfNull(json);
|
||||||
|
if (!shadowView) {
|
||||||
if (!json && !strongSelf->_defaultView) {
|
if (!json && !strongSelf->_defaultView) {
|
||||||
// Only create default view if json is null
|
// Only create default view if json is null
|
||||||
strongSelf->_defaultView = [strongSelf createViewWithTag:nil];
|
strongSelf->_defaultView = [strongSelf createViewWithTag:nil];
|
||||||
|
@ -161,6 +168,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||||
((void (*)(id, SEL, id, id, id))objc_msgSend)(
|
((void (*)(id, SEL, id, id, id))objc_msgSend)(
|
||||||
strongSelf.manager, customSetter, json, view, strongSelf->_defaultView
|
strongSelf.manager, customSetter, json, view, strongSelf->_defaultView
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
((void (*)(id, SEL, id, id))objc_msgSend)(
|
||||||
|
strongSelf.manager, customSetter, json, view
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} 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
|
* 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
|
* 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) \
|
#define RCT_CUSTOM_SHADOW_PROPERTY(name, type, viewClass) \
|
||||||
RCT_REMAP_SHADOW_PROPERTY(name, __custom__, type) \
|
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
|
@end
|
||||||
|
|
Loading…
Reference in New Issue