diff --git a/src/components/search/searchBodySection/SearchBodySection.tsx b/src/components/search/searchBodySection/SearchBodySection.tsx index 1004033..75a10c6 100644 --- a/src/components/search/searchBodySection/SearchBodySection.tsx +++ b/src/components/search/searchBodySection/SearchBodySection.tsx @@ -11,7 +11,7 @@ const SearchBodySection = () => { const router = useRouter(); const params = useSearchParams(); const [searchKeyword, setSearchKeyword] = useState(''); - const searchResult = useSearchQuery(searchKeyword); + const { data: searchResult, isPending } = useSearchQuery(searchKeyword); useEffect(() => { const searchParams = params.get('search')!; @@ -39,7 +39,7 @@ const SearchBodySection = () => { - + ); }; diff --git a/src/hooks/useSearchQuery.ts b/src/hooks/useSearchQuery.ts index 6cae2ef..8ba2f11 100644 --- a/src/hooks/useSearchQuery.ts +++ b/src/hooks/useSearchQuery.ts @@ -2,11 +2,10 @@ import { getSearchResult } from '@/apis/docs'; import { useQuery } from '@tanstack/react-query'; export const useSearchQuery = (searchKeyword: string) => { - const { data: searchResult } = useQuery({ + return useQuery({ queryKey: ['search', searchKeyword], queryFn: () => getSearchResult(searchKeyword), enabled: !!searchKeyword, staleTime: 60 * 1000, }); - return searchResult; };