#77SensorsEasy

useWindowScroll

useWindowScroll

React sensor hook that re-renders on window scroll.

Usage

import {useWindowScroll} from 'react-use';

const Demo = () => {
  const {x, y} = useWindowScroll();

  return (
    <div>
      <div>x: {x}</div>
      <div>y: {y}</div>
    </div>
  );
};
// TODO: implement useWindowScroll
function notImplemented(..._args: any[]): any {
  throw new Error('Not implemented');
}
export default notImplemented;
export const useWindowScroll = notImplemented;

Open browser consoleTests