{searchQuery && (
<div className="absolute left-0 top-12 w-full mx-auto max-h-96 bg-gray-200 rounded-lg overflow-y-scroll cursor-pointer text-black">
{filteredProducts.length > 0 ? (
<>
{searchQuery &&
filteredProducts.map((item: StoreProduct) => (
<Link
key={item._id}
className="w-full border-b-[1px] border-b-gray-400 flex items-center gap-4"
href={{
pathname: `${item._id}`,
query: {
_id: item._id,
brand: item.brand,
category: item.category,
description: item.description,
image: item.image,
isNew: item.isNew,
oldPrice: item.oldPrice,
price: item.price,
title: item.title,
},
}}
onClick={() => setSearchQuery("")}
>
<SearchProducts item={item} />
</Link>
))}
</>
) : (
<div className="bg-gray-50 flex items-center justify-center py-10 rounded-lg shadow-lg">
<p className="text-xl font-semibold animate-bounce">
Nothing is matches with your search keywords. Please try
again!
</p>
</div>
)}
</div>
)}
{searchQuery && (...)}.
괄호 안의 코드 블록이 searchQuery진실인 경우에만 렌더링