Skip to content

Commit

Permalink
Fix prefetchImageWithMetadata redbox in AMA
Browse files Browse the repository at this point in the history
Reviewed By: RSNara

Differential Revision: D24837264

fbshipit-source-id: b2aeef2c051fa15c06cf2eb6350c152b722196c2
  • Loading branch information
p-sun authored and facebook-github-bot committed Nov 10, 2020
1 parent 8f5656b commit f27e305
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ function prefetchWithMetadata(
rootTag?: ?number,
): any {
if (NativeImageLoaderIOS.prefetchImageWithMetadata) {
// number params like rootTag cannot be nullable before TurboModules is available
return NativeImageLoaderIOS.prefetchImageWithMetadata(
url,
queryRootName,
rootTag,
rootTag ? rootTag : 0,
);
} else {
return NativeImageLoaderIOS.prefetchImage(url);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/NativeImageLoaderIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface Spec extends TurboModule {
+prefetchImageWithMetadata?: (
uri: string,
queryRootName: string,
rootTag?: ?number,
rootTag: number,
) => Promise<boolean>;
+queryCache: (uris: Array<string>) => Promise<Object>;
}
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1197,12 +1197,12 @@ - (void)cancelRequest:(id)requestToken
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
[self prefetchImageWithMetadata:uri queryRootName:nil rootTag:nil resolve:resolve reject:reject];
[self prefetchImageWithMetadata:uri queryRootName:nil rootTag:0 resolve:resolve reject:reject];
}

RCT_EXPORT_METHOD(prefetchImageWithMetadata:(NSString *)uri
queryRootName:(NSString *)queryRootName
rootTag:(NSNumber *)rootTag
rootTag:(double)rootTag
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
Expand All @@ -1215,7 +1215,7 @@ - (void)cancelRequest:(id)requestToken
priority:RCTImageLoaderPriorityPrefetch
attribution:{
.queryRootName = queryRootName ? [queryRootName UTF8String] : "",
.surfaceId = [rootTag intValue],
.surfaceId = (int)rootTag,
}
progressBlock:nil
partialLoadBlock:nil
Expand Down

0 comments on commit f27e305

Please sign in to comment.