-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Hovering a Link component causes unnecessary useParams hook re-render. #58788
Comments
I found the same issue! It took me a whole day. |
I have finally had some time to look into this a bit more. |
Version v14.0.4 has been tested and the bug still exists. |
@ztanner, not sure if the behavior is directly correlated to your code, however, you might be a bit more familiar with the expected behavior surrounding this. Maybe you can have a look? |
Noticed the same issue on our site at work, on my current side project, but also on vercel Enregistrement.de.l.ecran.2024-01-15.a.14.31.00.mov |
Yes. In production only. |
this is partially-fixed in the latest canary version (tested) |
What version did you test? Because the bug still seems to be present as of |
@florian-lp |
Unfortunately seems to be present there as well for me. |
I tested canary.57 and canary.59, no fix. Because the |
I've finally had the time to fix this issue and have opened a pull request for it: #60708. |
…t to use PathParamsContext in the app router. (#60708) Moved app-dir path params parsing logic from `useParams` to `AppRouter`. This allows for the use of `PathParamsContext` in the `useParams` hook for both pages and app routers. In addition, this allows for memoization of the layout tree which fixes undesired re-renders of the `useParams` hook. Fixes [#58788](#58788) Closes NEXT-2434 --------- Co-authored-by: Zack Tanner <zacktanner@gmail.com>
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/florian-lp/next-link-rerender-bug
To Reproduce
Current vs. Expected behavior
Observed:
The component uses the useParams() hook to display the current dynamic path and logs this value to the browser console. When the is hovered this causes the useParams() hook to re-render the component, despite the actual path parameters not having been updated.
Expected:
Hovering the should not cause the useParams() hook to unnecessarily re-render when the path parameters have not been updated.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Additional context
This behavior has been present since release 14.0.2-canary.7. In release 14.0.2-canary.6 and below this was working.
This behavior is only present in production builds and not when running "npm run dev".
NEXT-2434
The text was updated successfully, but these errors were encountered: