From 14c93e4769614275ba6e946dba5744429a018a42 Mon Sep 17 00:00:00 2001 From: feb-dain Date: Thu, 16 Nov 2023 15:41:52 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B2=80=EC=83=89=20=EA=B2=B0=EA=B3=BC?= =?UTF-8?q?=EC=99=80=20=EA=B2=80=EC=83=89=EC=96=B4=EA=B0=80=20=EB=8F=99?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20=EC=95=88=20=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#927] --- .../hooks/useStationSearchWindow.tsx | 6 +----- frontend/src/hooks/useDebounce.ts | 13 ++----------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx b/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx index 79409ad97..fcebc74fa 100644 --- a/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx +++ b/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx @@ -35,7 +35,6 @@ export const useStationSearchWindow = () => { const [searchWord, setSearchWord] = useState(''); const [debouncedSearchWord, setDebouncedSearchWord] = useState(searchWord); const [userSearchWord, setUserSearchWord] = useState(''); - const [isSubmitted, setIsSubmitted] = useState(false); const { openLastPanel } = useNavigationBar(); const { openStationInfoWindow } = useStationInfoWindow(); @@ -46,8 +45,7 @@ export const useStationSearchWindow = () => { setDebouncedSearchWord(searchWord); }, [searchWord], - 400, - isSubmitted + 400 ); const { @@ -123,7 +121,6 @@ export const useStationSearchWindow = () => { const handleSubmitSearchWord = async (event: FormEvent) => { event.preventDefault(); handleCloseResult(); - setIsSubmitted(true); const searchWordFromForm = new FormData(event.currentTarget).get('station-search'); const encodedSearchWord = encodeURIComponent(String(searchWordFromForm)); @@ -148,7 +145,6 @@ export const useStationSearchWindow = () => { const handleChangeSearchWord = ({ target: { value } }: ChangeEvent) => { const searchWord = encodeURIComponent(value); - setIsSubmitted(false); handleOpenResult(); setSearchWord(searchWord); }; diff --git a/frontend/src/hooks/useDebounce.ts b/frontend/src/hooks/useDebounce.ts index 44cdaa57d..990de3738 100644 --- a/frontend/src/hooks/useDebounce.ts +++ b/frontend/src/hooks/useDebounce.ts @@ -1,20 +1,11 @@ import { useEffect, useCallback } from 'react'; -export const useDebounce = ( - func: (param: T) => void, - dependencies: string[], - delay: number, - shouldClear?: boolean -) => { +export const useDebounce = (func: (param: T) => void, dependencies: string[], delay: number) => { const callback = useCallback(func, dependencies); useEffect(() => { const timeout = setTimeout(callback, delay); - if (shouldClear) { - clearTimeout(timeout); - } - return () => clearTimeout(timeout); - }, [callback, delay, shouldClear]); + }, [callback, delay]); };