useScrollReact sensor hook that re-renders when the scroll position in a DOM element changes.
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>
);
};
useScroll(ref: RefObject<HTMLElement>);
// TODO: implement useScroll function notImplemented(..._args: any[]): any { throw new Error('Not implemented'); } export default notImplemented; export const useScroll = notImplemented;
Tests