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

Calling router.refresh() still resets client-side state in version 13.1.2 altought this was stated to be fixed in the Core Changes #44880

Open
1 task done
schimi-dev opened this issue Jan 14, 2023 · 0 comments
Labels
template: bug A user has filled out the bug report template. Issue needs triaging

Comments

@schimi-dev
Copy link

schimi-dev commented Jan 14, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 18.12.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.1.3-canary.0
eslint-config-next: 13.1.3-canary.0
react: 18.2.0
react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/schimi-dev/router-refresh-bug-report

To Reproduce

It seems that the bug concerning the resetting of state and Suspense boundaries is still present for navigation scenarios with dynamic routes when combined with data fetching in layouts.

In the example provided we have the following:
For the dynamic route app/[id] we have a layout that dynamically fetches two project resources with id 1 and id 2 and provides Links (next/link) to directly navigate between these two projects, while staying on the same page. The corresponding page fetches the single project for the id param it gets as prop and provides a Form as a Client Component for editing this project.

The bug can be reproduced as follows:

  1. Visit the details page of a dynamically fetched project.
  2. Change to the other project by using the Links of the layout.
  3. Edit the project and submit the Form. After a successful submit router.refresh() is called.

If you follow these steps the loss of client-side state still occurrs on the first call of router.refresh() after the dynamic id on that page was changed (navigated from one project to the other, while staying on the same page). This leads to the success state (rendering a success message with a green background) being lost.

Describe the Bug

In the Next.js release version 13.1.2 in the Core Changes it is stated that the loss of client-side state when calling router.refresh() was fixed:
Fix router.refresh() resetting state and Suspense boundaries #44775

However, there are navigation scenarios where a page can still be entered in a way that the first call of router.refresh() on that page leads to resetting client-side state.

Expected Behavior

No client side state should be lost when calling router.refresh() regardless of how the page calling it was entered before.

Which browser are you using? (if relevant)

108.0.5359.126

How are you deploying your application? (if relevant)

No response

@schimi-dev schimi-dev added the template: bug A user has filled out the bug report template. Issue needs triaging label Jan 14, 2023
@schimi-dev schimi-dev changed the title Calling router.refresh() still resets client-side state in Next.js version 13.1.2 altought this was stated to be fixed in the Core Changes Calling router.refresh() still resets client-side state in 13.1.2 altought this was stated to be fixed in the Core Changes of that version Jan 14, 2023
@schimi-dev schimi-dev changed the title Calling router.refresh() still resets client-side state in 13.1.2 altought this was stated to be fixed in the Core Changes of that version Calling router.refresh() still resets client-side state in version 13.1.2 altought this was stated to be fixed in the Core Changes Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
template: bug A user has filled out the bug report template. Issue needs triaging
Projects
None yet
Development

No branches or pull requests

1 participant