본문으로 건너뛰기

useWindowScrollTo

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>);
};