From 6af8f8b0c98d3c4812b8fe04dabd8a3ab4c8c820 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Thu, 18 Jul 2024 11:22:59 -0400 Subject: [PATCH] Implement prefetch for sdwebimage new arch --- packages/react-native/Libraries/Image/RCTImageLoader.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Image/RCTImageLoader.mm b/packages/react-native/Libraries/Image/RCTImageLoader.mm index 68a12d351227ef..6b3efbe7473dd1 100644 --- a/packages/react-native/Libraries/Image/RCTImageLoader.mm +++ b/packages/react-native/Libraries/Image/RCTImageLoader.mm @@ -10,6 +10,7 @@ #import #import +#import #import #import @@ -1222,7 +1223,12 @@ - (void)cancelRequest:(id)requestToken : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject) { - [self prefetchImageWithMetadata:uri queryRootName:nil rootTag:0 resolve:resolve reject:reject]; + NSURL *URL = [RCTConvert NSURL:uri]; + [SDWebImagePrefetcher.sharedImagePrefetcher prefetchURLs:@[ URL ] + progress:nil + completed:^(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls) { + resolve(@YES); + }]; } RCT_EXPORT_METHOD(prefetchImageWithMetadata