Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type definition in useWindowScroll #296

Open
pom421 opened this issue Apr 17, 2024 · 1 comment · May be fixed by #332
Open

Incorrect type definition in useWindowScroll #296

pom421 opened this issue Apr 17, 2024 · 1 comment · May be fixed by #332

Comments

@pom421
Copy link

pom421 commented Apr 17, 2024

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
Copy link
Author

pom421 commented Apr 17, 2024

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,
  ];
}

@mohammedhamza1 mohammedhamza1 linked a pull request Mar 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant