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

useLocale() usage in client component causes component reload on Link hover since next v14.0.2 (PROD build) #764

Closed
michal-th opened this issue Jan 9, 2024 · 1 comment
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@michal-th
Copy link

michal-th commented Jan 9, 2024

Description

Since i updated to nextjs 14.0.2+ (up to latest) i noticed that client components that use the useLocale() hook and contain Link component are behaving weirdly (sometimes even non-responsive) , upon further inspection i noticed they are being rapidly re-rendered when i repeatedly hover over the Links.

I created a simple reproduction sandbox, this can be reproduced only with production build (i believe it has to do with the fact Link prefetching is enabled only in prod build). This behaviour is not reproducible on 14.0.1 or previous nextjs versions.

Mandatory reproduction URL (CodeSandbox or GitHub repository)

CodeSandbox

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Execute Build & Start tasks
  3. See console log as you hover over TEST links repeatedly
  4. Commenting out the line with useLocale() hook stops the behaviour

Expected behaviour

Hovering the links shouldn't trigger the re-render & console.log() over and over

@michal-th michal-th added bug Something isn't working unconfirmed Needs triage. labels Jan 9, 2024
@amannn
Copy link
Owner

amannn commented Jan 9, 2024

Thanks for the report! That seems to be this bug upstream: vercel/next.js#58788 (useLocale uses useParams internally).

@amannn amannn closed this as completed Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants