[go: nahoru, domu]

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

Server component won't re-render when deleting all search params #64978

Closed
georgesofianosgr opened this issue Apr 24, 2024 · 10 comments
Closed
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@georgesofianosgr
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/elastic-sun-s3d7mt

To Reproduce

  1. Visit the link of the app with the search param fruit with a value, eg https://s3d7mt-3000.csb.app?fruit=apple
  2. Click the reset button that navigates user back to index page without search params, eg https://s3d7mt-3000.csb.app/

The page wont re-render.

Current vs. Expected behavior

In nextjs 14.1.1 if I remove all the search params the page will re-render.
In nextjs 14.2.2 and next@14.3.0-canary.21 the page won't re-render after removing the search params.
That only happens if you visit the page with search params from the start.

Our current workaround is to after pushing the page when there are not search params is to do router.refresh().

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.3.0-canary.21 // Latest available version is detected (14.3.0-canary.21).
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

No response

@georgesofianosgr georgesofianosgr added the bug Issue was opened via the bug report template. label Apr 24, 2024
@federicobadini
Copy link

Our ecommerce collection pages are often accessed with pre-populated query parameters, and this bug is preventing to go back to the unfiltered version of each collection.

As mentioned by @georgesofianosgr, when landing on a URL with query parameters and then navigating to the same URL without parameters, the RSC fails to execute properly.
Additionally, we've observed another related issue: after multiple transitions between URLs with and without search parameters, the page abruptly stops rendering any markup, with no errors appearing in the browser console.

You can view a video demonstrating both of these issues here:

Screen.Recording.2024-05-16.at.10.14.15.mov

Should you require it for further analysis, here's the references to the demo of the above video:

@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label May 20, 2024
@mortz123
Copy link

@georgesofianosgr @federicobadini hey guys, did you find any solution? i found myself in the same scenario - i followed next's guide to search and pagination (https://nextjs.org/learn/dashboard-app/adding-search-and-pagination) exactly but i still get this issue.

@federicobadini
Copy link

@mortz123 I personally rolled back to 14.1.4 which does not suffer from this issue.

@jinwoo0103
Copy link
jinwoo0103 commented Jun 5, 2024

It can be checked on v14.2.3, too.

In my case,

  1. user visits page with search param (ex. ?type=1) GOOD
  2. if user performs router replace action with other search param (ex. ?type=2) GOOD
  3. if user performs router replace action with search param deleted, it shows first visited state (ex. ?type=1) BAD

So, I think that nextjs does not distinguish "first visited search param state" and "no search param state".

@mortz123
Copy link

@mortz123 I personally rolled back to 14.1.4 which does not suffer from this issue.

Hey @federicobadini , how did you roll back? i tried to install next@14.1.4 but when i start my app, it seems broken like no styles are applying

@federicobadini
Copy link

@mortz123 I personally rolled back to 14.1.4 which does not suffer from this issue.

Hey @federicobadini , how did you roll back? i tried to install next@14.1.4 but when i start my app, it seems broken like no styles are applying

Have you ensured that all references to the previous node_modules folder have been removed? Try downgrading my minimal example to version 14.1.4. It should work correctly.

@ztanner
Copy link
Member
ztanner commented Jul 1, 2024

Hi - thanks for the report. I verified that this bug has been fixed on canary as of this PR which landed in v14.2.0-canary.58.

This should be coming to a stable release soon. In the meantime, please let us know if you are still seeing the unexpected behavior when testing it on the latest canary.

@ztanner ztanner closed this as completed Jul 1, 2024
@mortz123
Copy link
mortz123 commented Jul 1, 2024

Hi - thanks for the report. I verified that this bug has been fixed on canary as of this PR which landed in v14.2.0-canary.58.

This should be coming to a stable release soon. In the meantime, please let us know if you are still seeing the unexpected behavior when testing it on the latest canary.

glad to hear! thank you :) which version it should be when releasing? (14.2.4?)

@ztanner
Copy link
Member
ztanner commented Jul 1, 2024

Hi - thanks for the report. I verified that this bug has been fixed on canary as of this PR which landed in v14.2.0-canary.58.
This should be coming to a stable release soon. In the meantime, please let us know if you are still seeing the unexpected behavior when testing it on the latest canary.

glad to hear! thank you :) which version it should be when releasing? (14.2.4?)

14.2.4 has already been released, so it'll be in 14.2.5

@mortz123
Copy link
mortz123 commented Jul 2, 2024

Hi - thanks for the report. I verified that this bug has been fixed on canary as of this PR which landed in v14.2.0-canary.58.
This should be coming to a stable release soon. In the meantime, please let us know if you are still seeing the unexpected behavior when testing it on the latest canary.

glad to hear! thank you :) which version it should be when releasing? (14.2.4?)

14.2.4 has already been released, so it'll be in 14.2.5

ohh i see, thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

No branches or pull requests

5 participants