Skip to content

Incorrect type definition in useWindowScroll #296

@pom421

Description

@pom421

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

Activity

pom421

pom421 commented on Apr 17, 2024

@pom421
Author

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,
  ];
}
linked a pull request that will close this issue on Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @pom421

      Issue actions

        Incorrect type definition in useWindowScroll · Issue #296 · uidotdev/usehooks