From f940e7c4a61e6c29d88cf01b91f8fff1afe68b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 21 Dec 2015 10:03:59 -0800 Subject: [PATCH] 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). ``` ``` will make an error: ``` [RCTConvert.m:55] Error setting property 'source' of RCTImageView with tag #317: JSON value '' 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 --- React/Base/RCTImageSource.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Base/RCTImageSource.m b/React/Base/RCTImageSource.m index 3392385f8..07518edf9 100644 --- a/React/Base/RCTImageSource.m +++ b/React/Base/RCTImageSource.m @@ -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];