diff --git a/src/hooks/useSearchAutoCompleteQuery.ts b/src/hooks/useSearchAutoCompleteQuery.ts index 59317f7..8a5c829 100644 --- a/src/hooks/useSearchAutoCompleteQuery.ts +++ b/src/hooks/useSearchAutoCompleteQuery.ts @@ -1,23 +1,23 @@ import { getSearchResult } from '@/apis/docs'; import { useQuery } from '@tanstack/react-query'; -export const useSearchAutoCompleteQuery = (searchInput: string) => { +export const useSearchAutoCompleteQuery = (searchKeyword: string) => { const { data, isLoading } = useQuery({ - queryKey: ['autoComplete', searchInput], - queryFn: () => getSearchResult(searchInput), + queryKey: ['search', searchKeyword], + queryFn: () => getSearchResult(searchKeyword), select: (search) => { if (search.kind === 'searchResultList') { const titleList: string[] = []; search.data.forEach((data) => { - if (data.title.includes(searchInput)) titleList.push(data.title); - else if (data.content.includes(searchInput)) titleList.push(data.title); + if (data.title.includes(searchKeyword)) titleList.push(data.title); + else if (data.content.includes(searchKeyword)) titleList.push(data.title); }); return titleList; } else if (search.kind === 'searchResult') { return [search.data.title]; } }, - staleTime: 30 * 1000, + staleTime: 60 * 1000, }); return { data, isLoading }; };