Skip to content

Commit a69724b

Browse files
Merge pull request #919 from GetStream/vishal/image-memoization-fix-1
refactor: additional fixes for gallery memoizations
2 parents a715502 + 792a79b commit a69724b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

package/src/components/Attachment/Gallery.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const GalleryImage: React.FC<
5252

5353
return (
5454
<Image
55-
key={uri}
5655
{...rest}
5756
onError={() => setError(true)}
5857
source={{
@@ -70,7 +69,8 @@ const GalleryImage: React.FC<
7069
const MemoizedGalleryImage = React.memo(
7170
GalleryImage,
7271
(prevProps, nextProps) =>
73-
prevProps.height === nextProps.height && prevProps.uri === nextProps.uri,
72+
prevProps.height === nextProps.height &&
73+
getUrlWithoutParams(prevProps.uri) === getUrlWithoutParams(nextProps.uri),
7474
) as typeof GalleryImage;
7575

7676
const styles = StyleSheet.create({
@@ -258,7 +258,7 @@ const GalleryWithContext = <
258258
<TouchableOpacity
259259
activeOpacity={0.8}
260260
disabled={preventPress}
261-
key={`gallery-item-${url}/${rowIndex}/${images.length}`}
261+
key={`gallery-item-${messageId}/${colIndex}/${rowIndex}/${images.length}`}
262262
onLongPress={(event) => {
263263
if (onLongPress) {
264264
onLongPress({

0 commit comments

Comments
 (0)