The Scroller component renders a UI containing two buttons: one for scrolling to the top of the page and one for scrolling to the bottom. It requires two callback functions via props to handle the scroll logic, as the component does not manage the scroll state itself.
import { Scroller } from './components/scroller/component';
function MyComponent() {
const handleScrollTop = () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
const handleScrollBottom = () => {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
};
return (
<Scroller
onClickScrollTop={handleScrollTop}
onClickScrollBottom={handleScrollBottom}
/>
);
}