From daa704007240e6f3111a0f47887e1d43a8127741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=ED=9D=AC?= Date: Sun, 25 Feb 2024 01:12:34 +0900 Subject: [PATCH] =?UTF-8?q?FEAT=20:=20=EB=AC=B4=ED=95=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A1=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MainPage/List.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MainPage/List.tsx b/src/MainPage/List.tsx index 632a8490..538f119c 100644 --- a/src/MainPage/List.tsx +++ b/src/MainPage/List.tsx @@ -218,7 +218,12 @@ const Post = () => { try { const response = await axios.get(`/article?pageNumber=${pageNumber}`); const newData = response.data.article; - setArticleData((prevData) => [...prevData, ...newData]); // 기존 데이터와 새로운 데이터 결합 + if (newData.length > 0) { + setArticleData((prevData) => [...prevData, ...newData]); // 기존 데이터와 새로운 데이터 결합 + setPageNumber((prevPageNumber) => prevPageNumber + 1); // 페이지 번호 증가 + } else { + // 데이터가 없는 경우, 더 이상 가져올 데이터가 없음을 나타낼 수 있는 처리를 추가 + } } catch (error) { console.error('Error fetching user data:', error); }