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

useRouter hook is not memoized #28

Open
alexcracea opened this issue Mar 16, 2024 · 2 comments
Open

useRouter hook is not memoized #28

alexcracea opened this issue Mar 16, 2024 · 2 comments
Assignees

Comments

@alexcracea
Copy link

alexcracea commented Mar 16, 2024

Describe the bug
When using use useRouter hook from next13-progressbar it is never memoized and causes an infinite loop when using it as a dependency for useEffect

To Reproduce
Steps to reproduce the behavior:

import { useEffect } from "react";
import { useRouter } from "next13-progressbar";

export function Example() {
  const router = useRouter();

  useEffect(() => {
    console.log("I will infinitely repeat");
  }, [router]);

  return (
    <div>
      <h1>Example</h1>
    </div>
  );
}

Expected behavior
The useRouter instance should never re-trigger a change when used inside a useEffect

@ndungtse
Copy link
Owner

I don't know but in my case using it as dependency in useEffect don't cause infinite loop. So maybe you can check if there may be another reason for it.

@ndungtse ndungtse closed this as completed May 2, 2024
@ndungtse ndungtse reopened this May 2, 2024
@Kazizodev
Copy link

Kazizodev commented Aug 29, 2024

This is happening with me as well, including router in my useEffect is causing an infinite repeat. Using Next.js 14 with Typescript

Edit: Using the normal Next.js router doesn't do an infinite repeat.

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

No branches or pull requests

3 participants