From 71d7d6883cb9a3d18666f04a444de7b4a611b304 Mon Sep 17 00:00:00 2001 From: jsfu Date: Wed, 14 Aug 2019 03:26:59 -0700 Subject: [PATCH] fix display problems when image fails to load (#25969) Summary: This problem was also affecting Fabric and was fixed in D16708532. When the image resource is changed and the new image resource fails to load, we expect the display image to fail to load, but the image still shows the image that was successfully loaded last time. ## Changelog [iOS] [Fixed] - fix display problems when image fails to load Pull Request resolved: https://github.com/facebook/react-native/pull/25969 Test Plan: This is catalyst playground with following code P78264143. TLDR of the code, it sets URL that is 404. {F175486515} Reviewed By: makovkastar Differential Revision: D16783330 Pulled By: sammy-SC fbshipit-source-id: 1cb488590ce15d957357f32a73ebf8df6cccf4cd --- Libraries/Image/RCTImageView.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/Image/RCTImageView.m b/Libraries/Image/RCTImageView.m index 6265828de9ef5e..3642dce35840bc 100644 --- a/Libraries/Image/RCTImageView.m +++ b/Libraries/Image/RCTImageView.m @@ -347,6 +347,10 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage error:(NSError *)error for } if (error) { + RCTExecuteOnMainQueue(^{ + self.image = nil; + }); + if (_onError) { _onError(@{ @"error": error.localizedDescription }); }