소스 검색

determine if a string that has been debounced is empty

Shun Miyazawa 2 년 전
부모
커밋
5d05f2ad66
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      apps/app/src/features/search/client/components/SearchResultMenuItem.tsx

+ 3 - 3
apps/app/src/features/search/client/components/SearchResultMenuItem.tsx

@@ -12,11 +12,11 @@ type Props = {
 export const SearchResultMenuItem = (props: Props): JSX.Element => {
   const { searchKeyword } = props;
 
-  const isEmptyKeyword = searchKeyword.trim() === '';
-
   const debouncedKeyword = useDebounce(searchKeyword, 500);
 
-  const { data: searchResult } = useSWRxSearch(isEmptyKeyword ? null : debouncedKeyword, null, { limit: 10 });
+  const isEmptyKeyword = debouncedKeyword.trim() === '';
+
+  const { data: searchResult } = useSWRxSearch(isEmptyKeyword ? null : searchKeyword, null, { limit: 10 });
 
   if (isEmptyKeyword || searchResult == null || searchResult.data.length === 0) {
     return <></>;