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
Labels
template: bug
A user has filled out the bug report template. Issue needs triaging
Verify 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 alayout
that dynamically fetches two project resources with id1
and id2
and provides Links (next/link
) to directly navigate between these two projects, while staying on the same page. The correspondingpage
fetches the single project for theid
param it gets as prop and provides a Form as a Client Component for editing this project.The bug can be reproduced as follows:
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 callingrouter.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
The text was updated successfully, but these errors were encountered: