useWindowScrollPosition
Aboutβ
A React hook to get the scroll position of the window
Installationβ
npm install --save rooks
Importing the hookβ
import { useWindowScrollPosition } from 'rooks';
Usageβ
function Demo() {
const { scrollX, scrollY } = useWindowScrollPosition();
return (
<div>
<p> Window X position is {scrollX}</p>
<p> Window Y position is {scrollY}</p>
</div>
);
}
render(<Demo />);
Codesandbox Examplesβ
Basic Usageβ
Join Bhargav's discord serverβ
You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.