Skip to content

Files

Latest commit

a0ba145 Β· Jan 9, 2020

History

History
25 lines (19 loc) Β· 374 Bytes

useWindowScroll.md

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>
  );
};