import React, { useRef } from 'react';
function MyComponent() {
const myRef = useRef(null);
const handleScroll = () => {
const { scrollHeight, clientHeight, scrollTop } = myRef.current;
if (scrollHeight - clientHeight <= scrollTop + 1) {
console.log('Reached bottom');
}
};
return (
<div ref={myRef} onScroll={handleScroll} style={{ height: '500px', overflow: 'auto' }}>
{/* Your content */}
</div> );
}