Reuse objects to prevent re-renders

This commit is contained in:
Eric Bailey
2024-08-02 12:49:43 -05:00
parent 7d01503f07
commit 69fac754d1
+2 -7
View File
@@ -75,12 +75,7 @@ export const ProfileLists = React.forwardRef<SectionRef, ProfileListsProps>(
items = items.concat([EMPTY])
} else if (data?.pages) {
for (const page of data?.pages) {
items = items.concat(
page.lists.map(l => ({
...l,
_reactKey: l.uri,
})),
)
items = items.concat(page.lists)
}
}
if (isError && !isEmpty) {
@@ -192,7 +187,7 @@ export const ProfileLists = React.forwardRef<SectionRef, ProfileListsProps>(
testID={testID ? `${testID}-flatlist` : undefined}
ref={scrollElRef}
data={items}
keyExtractor={(item: any) => item._reactKey}
keyExtractor={(item: any) => item._reactKey || item.uri}
renderItem={renderItemInner}
refreshing={isPTRing}
onRefresh={onRefresh}