You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run this code to reproduce the problem, Or use the sandbox link:
importLinkfrom"next/link";constComponentOne=()=>{console.log("ComponentOne");return<div>ComponentOne</div>;}constComponentTwo=()=>{console.log("ComponentTwo");return<div>ComponentTwo</div>;}functionIndex(){return(<div><Linkhref="/">
Click on link to cause rerendering!
</Link><ComponentOne/><ComponentTwo/></div>);}exportdefaultIndex;
Describe the Bug
Using Nextjs Link with current page path as href without any query params or changes causes re-rendering of the whole page.
Expected Behavior
Do not re-render the whole page when href is a path to the exact current page path.
Re-rendering could happen within following scenarios:
Link href has query params (With detecting changes in their values???) if it is used for current page (Assume the page path is /pages/SomeRoute.tsx):
functionIndex(){return(<div><Linkhref={{pathname: "SomeRoute",query: {param1: "value1",}}}>
Click on link to cause rerendering!
</Link><ComponentOne/><ComponentTwo/></div>);}
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
Verify canary release
Provide environment information
❯ npx --no-install next info Operating System: Platform: linux Arch: x64 Version: #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023 Binaries: Node: 18.12.1 npm: 8.19.2 Yarn: 1.22.10 pnpm: N/A Relevant packages: next: 13.1.1 eslint-config-next: 12.3.4 react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
https://codesandbox.io/s/affectionate-rubin-rqrypw?file=/pages/index.tsx
To Reproduce
Run this code to reproduce the problem, Or use the sandbox link:
Describe the Bug
Using Nextjs
Link
with current page path as href without any query params or changes causes re-rendering of the whole page.Expected Behavior
Do not re-render the whole page when
href
is a path to the exact current page path.Re-rendering could happen within following scenarios:
useRouter
hook:href
has query params (With detecting changes in their values???) if it is used for current page (Assume the page path is/pages/SomeRoute.tsx
):Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: