From 4c2c861fe896d2235537ebdaa1a641ccab28ac74 Mon Sep 17 00:00:00 2001 From: feb-dain Date: Tue, 14 Nov 2023 12:19:56 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 다른 코드들 처럼 hook끼리 모아두기로 결정 [#927] --- .../hooks/useStationSearchWindow.tsx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx b/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx index ed0baaee..19a88966 100644 --- a/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx +++ b/frontend/src/components/ui/StationSearchWindow/hooks/useStationSearchWindow.tsx @@ -29,6 +29,23 @@ export const useStationSearchWindow = () => { const [isFocused, setIsFocused] = useState(false); + const queryClient = useQueryClient(); + + const [searchWord, setSearchWord] = useState(''); + const [debouncedSearchWord, setDebouncedSearchWord] = useState(searchWord); + + const { openLastPanel } = useNavigationBar(); + const { openStationInfoWindow } = useStationInfoWindow(); + const { renderDefaultMarker } = useMarker(); + + useDebounce( + () => { + setDebouncedSearchWord(searchWord); + }, + [searchWord], + 400 + ); + const handleOpenResult = ( event?: MouseEvent | FocusEvent ) => { @@ -43,19 +60,6 @@ export const useStationSearchWindow = () => { setIsFocused(false); }; - const queryClient = useQueryClient(); - - const [searchWord, setSearchWord] = useState(''); - const [debouncedSearchWord, setDebouncedSearchWord] = useState(searchWord); - - useDebounce( - () => { - setDebouncedSearchWord(searchWord); - }, - [searchWord], - 400 - ); - const handleSubmitSearchWord = async (event: FormEvent) => { event.preventDefault(); @@ -81,10 +85,6 @@ export const useStationSearchWindow = () => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY_SEARCHED_STATION] }); }; - const { openLastPanel } = useNavigationBar(); - const { openStationInfoWindow } = useStationInfoWindow(); - const { renderDefaultMarker } = useMarker(); - const showStationDetails = async ({ stationId, latitude, longitude }: StationPosition) => { googleMapActions.moveTo({ lat: latitude, lng: longitude });