use-scroll-to-bottom
React Hook which tells you when you've scrolled to bottom
Uses IntersectionObserver so make sure you can support it.
![NPM](https://img.shields.io/npm/v/use-scroll-to-bottom.svg)
Install
npm install --save use-scroll-to-bottom
Usage
The hook returns a tuple of two things:
- A RefCallback which needs to go on the last element of your scrolling container.
- A boolean value which tells you whether bottom has been reached or not.
Check demo and examples
import React from 'react';
import {useScrollToBottom} from 'use-scroll-to-bottom'
export default function MyComponent() {
const [setBottomRef, isBottom] = useScrollToBottom();
return (
<div className="simple-container">
<div className="big-element">
{isBottom && "Bottom reached"}
</div>
<div ref={setBottomRef}>Bottom</div>
</div>
)
}
License
MIT © tudorgergely