Get scrolling value quickly by React hook
npm install @react-hooks-custom/use-scrollnpm i @react-hooks-custom/use-scroll
A React hook for updating components when the scroll position of the window on the y-axis changes.
``
import useScroll from '@react-hooks-custom/use-scroll'
const Component = (props) => {
const { scrollX, scrollY } = useScroll();
return
API
#### useScroll () => ScrollType
`
type ScrollType = {
scrollX: number;
scrollY: number;
}
``#### Returns { scrollX, scrollY }
|| Type | Description
---|---|---
scrollX | number | The current scroll position of the window on the x-axis
scrollY | number | The current scroll position of the window on the y-axis
MIT