Skip to content

Commit 2f29284

Browse files
committed
Add cacheKey prop to ExpoImage
1 parent cc665b3 commit 2f29284

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/core/src/components/ExpoImage.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface ExtendedImageProps extends ExpoImageProps {
2424
allowDownscaling?: boolean;
2525
blurRadius?: number;
2626
blurhash?: string;
27+
cacheKey?: string;
2728
}
2829

2930
const resizeModeToContentFit = (
@@ -52,9 +53,25 @@ const ExpoImage: React.FC<ExtendedImageProps> = ({
5253
allowDownscaling = true,
5354
blurRadius,
5455
blurhash,
56+
cacheKey,
5557
...props
5658
}) => {
57-
const imageSource = source ?? Config.placeholderImageURL;
59+
let imageSource = source ?? Config.placeholderImageURL;
60+
61+
if (cacheKey) {
62+
if (typeof source === "object" && "uri" in source) {
63+
imageSource = {
64+
...source,
65+
cacheKey,
66+
};
67+
} else if (typeof source === "string") {
68+
imageSource = {
69+
uri: source,
70+
cacheKey,
71+
};
72+
}
73+
}
74+
5875
const finalContentFit = resizeMode
5976
? resizeModeToContentFit(resizeMode)
6077
: contentFit;

0 commit comments

Comments
 (0)