Skip to content

Latest commit

Β 

History

History
25 lines (19 loc) Β· 374 Bytes

File metadata and controls

25 lines (19 loc) Β· 374 Bytes

πŸ₯– useWindowScroll

Re-renders on window scroll.

Returns

  • state: Object
    • x: Number: Horizontal location
    • y: Number: Vertical location

Usage

import { useWindowScroll } from "react-recipes";

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

  return (
    <div>
      <div>x: {x}</div>
      <div>y: {y}</div>
    </div>
  );
};