From c145489886202a60627251cb2928ad65368184de Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Wed, 28 Dec 2022 13:31:26 +0300 Subject: [PATCH] perf(improve-fetchmatc): hes-login --- src/features/Matches/hooks.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/features/Matches/hooks.tsx b/src/features/Matches/hooks.tsx index 4f0bd402..95eb4d60 100644 --- a/src/features/Matches/hooks.tsx +++ b/src/features/Matches/hooks.tsx @@ -13,6 +13,8 @@ import { useRequest } from 'hooks' import { usePreferencesStore } from 'features/PreferencesPopup' import { isMobileDevice } from 'config/userAgent' +import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams' + import { prepareMatches } from './helpers/prepareMatches' export type Match = ReturnType[number] @@ -66,13 +68,18 @@ export const useMatches = ({ fetch }: Props) => { isFetching, ]) + const dateParam = checkUrlParams('date') + useEffect(() => { - fetchMatches(0).then(setMatches) - pageRef.current = 1 + if (dateParam) { + fetchMatches(0).then(setMatches) + pageRef.current = 1 + } return () => { setMatches(initialState) } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [fetchMatches, userPreferences]) const preparedMatches = useMemo(() => ({