Skip to content

Commit

Permalink
memoize the search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzaizzat committed Apr 23, 2024
1 parent d79bee3 commit 99ac673
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions apps/mobile/src/screens/GalleryScreen/GalleryEditorNftSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native';
import { Suspense, useCallback } from 'react';
import { Suspense, useCallback, useMemo } from 'react';
import { View } from 'react-native';
import { noop } from 'shared/utils/noop';

import { NftSelectorHeader } from '~/components/NftSelector/NftSelectorHeader';
import { NftSelectorToolbar } from '~/components/NftSelector/NftSelectorToolbar';
Expand Down Expand Up @@ -42,6 +43,16 @@ export function GalleryEditorNftSelector() {
[navigation, route.params.galleryId]
);

const searchCriteria = useMemo(
() => ({
searchQuery,
ownerFilter: ownershipTypeFilter,
networkFilter: networkFilter,
sortView,
}),
[searchQuery, ownershipTypeFilter, networkFilter, sortView]
);

return (
<NftSelectorWrapper ownershipTypeFilter={ownershipTypeFilter} isFullscreen>
<View className="gap-8">
Expand All @@ -63,15 +74,10 @@ export function GalleryEditorNftSelector() {
<View className="flex-grow flex-1 w-full">
<Suspense fallback={<NftSelectorLoadingSkeleton />}>
<NftSelectorPickerGrid
searchCriteria={{
searchQuery,
ownerFilter: ownershipTypeFilter,
networkFilter: networkFilter,
sortView,
}}
searchCriteria={searchCriteria}
onRefresh={sync}
onSelect={handleSelectNft}
onSelectNftGroup={() => {}}
onSelectNftGroup={noop}
/>
</Suspense>
</View>
Expand Down

0 comments on commit 99ac673

Please sign in to comment.