Skip to content

Commit f137f01

Browse files
committed
fix: memoize the photos
1 parent dcd8919 commit f137f01

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

package/src/components/AttachmentPicker/AttachmentPicker.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useRef, useState } from 'react';
1+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
import { BackHandler, Keyboard, Platform, StyleSheet } from 'react-native';
33

44
import BottomSheetOriginal from '@gorhom/bottom-sheet';
@@ -230,11 +230,15 @@ export const AttachmentPicker = React.forwardRef(
230230
}
231231
}, [currentIndex, selectedPicker, getMorePhotos, loadingPhotos]);
232232

233-
const selectedPhotos = photos.map((asset) => ({
234-
asset,
235-
ImageOverlaySelectedComponent,
236-
numberOfAttachmentPickerImageColumns,
237-
}));
233+
const selectedPhotos = useMemo(
234+
() =>
235+
photos.map((asset) => ({
236+
asset,
237+
ImageOverlaySelectedComponent,
238+
numberOfAttachmentPickerImageColumns,
239+
})),
240+
[photos, ImageOverlaySelectedComponent, numberOfAttachmentPickerImageColumns],
241+
);
238242

239243
const handleHeight = attachmentPickerBottomSheetHandleHeight;
240244

0 commit comments

Comments
 (0)