Skip to content

Commit

Permalink
FEAT : 무한 스크롤 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
junvhui committed Feb 24, 2024
1 parent daa7040 commit ac47e04
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/MainPage/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,7 @@ const Post = () => {
try {
const response = await axios.get(`/article?pageNumber=${pageNumber}`);
const newData = response.data.article;
if (newData.length > 0) {
setArticleData((prevData) => [...prevData, ...newData]); // 기존 데이터와 새로운 데이터 결합
setPageNumber((prevPageNumber) => prevPageNumber + 1); // 페이지 번호 증가
} else {
// 데이터가 없는 경우, 더 이상 가져올 데이터가 없음을 나타낼 수 있는 처리를 추가
}
setArticleData((prevData) => [...prevData, ...newData]); // 기존 데이터와 새로운 데이터 결합
} catch (error) {
console.error('Error fetching user data:', error);
}
Expand Down

0 comments on commit ac47e04

Please sign in to comment.