mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
iOS: Fix Image source={{ uri: null }} to crash
Summary: this is a recent regression because the error appeared in my app (from 0.16 to 0.17). ``` <Image source={{ uri: null }} /> ``` will make an error: ``` [RCTConvert.m:55] Error setting property 'source' of RCTImageView with tag #317: JSON value '<null>' of type NSNull cannot be converted to NSString ``` The solution attached is to check that uri is a NSString and return nil if not (the same way nil is returned in case of invalid url). Closes https://github.com/facebook/react-native/pull/4902 Reviewed By: svcscm Differential Revision: D2779789 Pulled By: nicklockwood fb-gh-sync-id: cfe429ec5e53e63b7b368c06e693424ca8aaa11e
This commit is contained in:
parent
a99c5160ee
commit
f940e7c4a6
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#import "RCTImageSource.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@interface RCTImageSource ()
|
||||
|
||||
@ -60,7 +61,7 @@
|
||||
CGFloat scale = 1.0;
|
||||
BOOL packagerAsset = NO;
|
||||
if ([json isKindOfClass:[NSDictionary class]]) {
|
||||
if (!(imageURL = [self NSURL:json[@"uri"]])) {
|
||||
if (!(imageURL = [self NSURL:RCTNilIfNull(json[@"uri"])])) {
|
||||
return nil;
|
||||
}
|
||||
size = [self CGSize:json];
|
||||
|
Loading…
x
Reference in New Issue
Block a user