Skip to content

Commit

Permalink
refector: 옵셔널 체이닝 리펙토링
Browse files Browse the repository at this point in the history
  • Loading branch information
minjeoong committed Jan 18, 2025
1 parent cfde29a commit ae329b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/page/community/search/index/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Search = () => {
const [searchParams] = useSearchParams();
const query = searchParams.get("searchText");
const [searchText, setSearchText] = useState(query || "");
const { data: recentSearchData } = useSearchGet();
const { data: recentSearchData, isLoading } = useSearchGet();

const inputRef = useRef<HTMLInputElement>(null);

Expand Down Expand Up @@ -40,6 +40,8 @@ const Search = () => {
}
}, []);

if (!recentSearchData || !recentSearchData.keywords || isLoading) return null;

return (
<div className={styles.container}>
<div className={styles.searchHeader}>
Expand All @@ -57,7 +59,7 @@ const Search = () => {
<div className={styles.searchContent}>
<div className={styles.title}>최근 검색 기록</div>
<ul className={styles.list}>
{recentSearchData?.keywords?.map((data) => (
{recentSearchData.keywords.map((data) => (
<li
key={data.id}
className={styles.listItem}
Expand Down

0 comments on commit ae329b3

Please sign in to comment.