From ae783336a32720536018ea5e25c2dfea1f9a7aba Mon Sep 17 00:00:00 2001 From: kikukiku1111111 Date: Thu, 29 Aug 2024 18:09:52 +0900 Subject: [PATCH] create-more-look-button --- .../src/pages/customize/company/industry.tsx | 24 ++++++++++++++----- frontend/src/pages/home.tsx | 16 +++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/customize/company/industry.tsx b/frontend/src/pages/customize/company/industry.tsx index 55285f7..126c140 100644 --- a/frontend/src/pages/customize/company/industry.tsx +++ b/frontend/src/pages/customize/company/industry.tsx @@ -18,6 +18,7 @@ export default function CompanyList() { const [selectedCompanies, setSelectedCompanies] = useState([]) const [loading, setLoading] = useState(false) const [error, setError] = useState(false) + const [itemsToShow, setItemsToShow] = useState(15) // 表示するアイテム数の初期値を15に設定 useEffect(() => { const fetchCompanyData = async () => { @@ -63,6 +64,10 @@ export default function CompanyList() { setSelectedCompanies(newChecked) } + const handleLoadMore = () => { + setItemsToShow(itemsToShow + 15) // さらに15件を表示 + } + const handleSubmit = async () => { try { const response = await fetch('http://localhost:8000/test', { @@ -106,13 +111,9 @@ export default function CompanyList() { - {companyData.map((company) => ( + {companyData.slice(0, itemsToShow).map((company) => ( @@ -138,6 +139,17 @@ export default function CompanyList() { ))} + {itemsToShow < companyData.length && ( + + + + )} + + )} )