usehooks icon indicating copy to clipboard operation
usehooks copied to clipboard

Incorrect type definition in useWindowScroll

Open pom421 opened this issue 1 year ago • 1 comments

Hi,

When I use useWindowScroll,

  useEffect(() => {
    scrollTo(0, 0);
  }, [scrollTo]);

The compiler says "Expected 1 arguments, but got 2.".

Effectively, the index.d.ts is incorrect :


  export function useWindowScroll(): [
    {
      x: number | null;
      y: number | null;
    },
    (args: unknown) => void
  ];

pom421 avatar Apr 17 '24 09:04 pom421

For readers in a hurry, I have used this quickfix in my code 👍🏼

declare module "@uidotdev/usehooks" {
  function useWindowScroll(): [
    {
      x: number | null;
      y: number | null;
    },
    (row: number, col: number) => void,
  ];
}

pom421 avatar Apr 17 '24 09:04 pom421