infinite scroll

js·2022년 5월 13일
0

intersection observer api

새로 알게 된것

const fetchMoreObserver = new IntersectionObserver(([{ isIntersecting }]) => {
  if (isIntersecting) fetchMore();
});

([{ isIntersecting }])

: 배열의 첫번째 요소의 property인 isIntersecting을 받는 구조 분해 할당 문법

어차피 첫번째 entry의 isIntersecting 값만 알면 되니 반목문 돌리고 entry.isIntersecting 값을 받아오는 식으로 코드를 작성 하지 않아도 된다.

0개의 댓글