Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchFilterSync from '@hooks/useSearchFilterSync';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {close} from '@libs/actions/Modal';
Expand Down Expand Up @@ -88,7 +87,6 @@ function useSearchFiltersBar(queryJSON: SearchQueryJSON, isMobileSelectionModeEn
const {isOffline} = useNetwork();
const personalDetails = usePersonalDetails();
const filterFormValues = useFilterFormValues(queryJSON);
useSearchFilterSync(filterFormValues);
const {shouldUseNarrowLayout, isLargeScreenWidth} = useResponsiveLayout();
const {selectedTransactions, shouldShowFiltersBarLoading, currentSearchResults} = useSearchStateContext();
const {currencyList} = useCurrencyListState();
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Search/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {useSearchActionsContext, useSearchStateContext} from '@components/Search
import type {SearchParams} from '@components/Search/types';
import {usePlaybackActionsContext} from '@components/VideoPlayerContexts/PlaybackContext';
import useConfirmReadyToOpenApp from '@hooks/useConfirmReadyToOpenApp';
import useFilterFormValues from '@hooks/useFilterFormValues';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useMobileSelectionMode from '@hooks/useMobileSelectionMode';
import usePrevious from '@hooks/usePrevious';
import useReceiptScanDrop from '@hooks/useReceiptScanDrop';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchFilterSync from '@hooks/useSearchFilterSync';
import useSearchShouldCalculateTotals from '@hooks/useSearchShouldCalculateTotals';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -40,6 +42,8 @@ function SearchPage({route}: SearchPageProps) {
const isMobileSelectionModeEnabled = useMobileSelectionMode(clearSelectedTransactions);

const queryJSON = useMemo(() => buildSearchQueryJSON(route.params.q, route.params.rawQuery), [route.params.q, route.params.rawQuery]);
const filterFormValues = useFilterFormValues(queryJSON);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep filter-form subscriptions out of SearchPage

useFilterFormValues() subscribes to broad Onyx collections (CARD_LIST, POLICY, REPORT, etc. in src/hooks/useFilterFormValues.tsx), and this new call in SearchPage makes the entire page re-render whenever those datasets change, even if the search query is unchanged. Because useSearchFiltersBar still calls useFilterFormValues(queryJSON), this commit introduces a second subscription path and expands the rerender scope from the filter bar to the full search screen, which can noticeably degrade performance during frequent Onyx/Pusher updates.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useSearchFilterSync(filterFormValues);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['SmartScan'] as const);

const lastNonEmptySearchResults = useRef<SearchResults | undefined>(undefined);
Expand Down
Loading