Skip to content

Commit

Permalink
FEAT : 무한 스크롤 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
junvhui committed Feb 25, 2024
1 parent 66864f5 commit 7b70c08
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/MainPage/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ const Post = () => {
// 이적 기사 최신순 정렬

console.log(articleData);
console.log('article');

// Intersection Observer를 이용하여 무한 스크롤 감지
const [pageNumber, setPageNumber] = useState(1);
Expand All @@ -217,8 +218,8 @@ const Post = () => {
const fetchData = async () => {
try {
const response = await axios.get(`/article?pageNumber=${pageNumber}`);
const newData = response.data.article;
console.log(newData);
const newData = response.data.article.reverse();

setArticleData((prevData) => [...prevData, ...newData]); // 기존 데이터와 새로운 데이터 결합
} catch (error) {
console.error('Error fetching user data:', error);
Expand Down

0 comments on commit 7b70c08

Please sign in to comment.