-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.locked
Description
Bug report
Depending on the push function of useRouter causes an infinite loop when the push function is called from inside a useEffect
To Reproduce
- Set up a catch-all optional dynamic route
[[...slug]].js - Render the following component from this page
Example component
const BugExample = () => {
useEffect(() => {
push('/[[...slug]]', '/123/test', { shallow: true })
console.log('called');
},[push])
return null
}
You will see an infinite loop of called in the console
Expected behavior
Push should be a non-changing reference, so that the react diff algoirithm knows not to call side effects again uneccesarily
System information
- OS: macOs
- Browser: Chrome
- Version of Next.js: 9.5
- Version of Node.js: 13.2.0
izorg, ciampo, mattiasw, hkgittt, jacknewberry and 52 more
Metadata
Metadata
Assignees
Labels
linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.locked