Skip to content

Commit

Permalink
Implement prefetch for sdwebimage new arch
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Nov 3, 2024
1 parent b835243 commit 6af8f8b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/react-native/Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import <atomic>

#import <ImageIO/ImageIO.h>
#import <SDWebImage/SDWebImage.h>

#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <React/RCTConvert.h>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6af8f8b

Please sign in to comment.