infinite scroll

참고

Infinite-scroll use React hooks

const options = {threshold: 0}
const observer = new IntersectionObserver((entries, observer) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            observer.unobserve(entry.target)
            entry.target.src = entry.target.dataset.src
        }
    })
}, options)
observer.observe(Array.from(document.getElementsByClassName('lazy')))

업데이트: