|
Download react-use/docs/useScroll.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 430 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useScroll.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useScroll.md
-
curl -L -o useScroll.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useScroll.md
430 Bytes
useScroll
React sensor hook that re-renders when the scroll position in a DOM element changes.
Usage
import {useScroll} from 'react-use';
const Demo = () => {
const scrollRef = React.useRef(null);
const {x, y} = useScroll(scrollRef);
return (
<div ref={scrollRef}>
<div>x: {x}</div>
<div>y: {y}</div>
</div>
);
};
Reference
useScroll(ref: RefObject<HTMLElement>);