diff --git a/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx b/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx index 79409ad9..fcebc74f 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 44cdaa57..990de373 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]); };