next13-progressbar
next13-progressbar copied to clipboard
`useRouter` hook is not memoized
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
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.
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.