Vanilla js에서는 window.addEventListener('scroll', callback)
형태로 사용한다.
React js에서 특정 component에 onScroll 을 붙여서 사용할 수 있다.
예를 들면) Ant Design의 Modal Component를 사용하는데, 거기에 overflow: scroll
이 있다면 해당 element (예를 들면 div)에 onScroll을 붙인다.
const MyComponent = () => {
return (
<Modal>
<div className="list-container" onScroll={() => console.log('scrolled')}>
What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries,
but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</Modal>
)
}