Skip to main content

useWindowScrollTo

A custom hook to conveniently call window.scrollTo().


Interface

interface UseScrollToProps {
left?: ScrollToOptions['left']; // default: 0
top?: ScrollToOptions['top']; // default: 0
behavior?: ScrollToOptions['behavior']; // default: 'auto'
dependencies?: DependencyList; // default: []
}

const useWindowScrollTo: ({
left,
top,
behavior,
dependencies,
}?: UseScrollToProps) => void;

Usage

import { useWindowScrollTo } from '@devgrace/react';

const Example = () => {
useWindowScrollTo();

return (<div>{/* ... */}</div>);
};