You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
useCanGoBack causes hydration error on page refresh #8211
there are 2 pages in the repro Start project - Page 1 and Page 2
navigate to Page 2 from Page 1 by clicking the "Page 2" link
Page 2 calls useCanGoBack and because of the browser history, it returns true as expected
Hello "/(test)/page2 can go back"! is displayed
if you refresh the browser after navigating to Page 2, a hydration mismatch error is thrown and displayed in the console. It appears that the server renders canGoBack = false (empty history), but the client hydrates with true (history still contains Page1).
Expected behavior
I was expecting no hydration error - but maybe this is just a known limitation for using the hook.
A user in discord suggested conditionally rendering ui after a useEffect runs but this seems a little hacky.
If this is a known limitation, I'm curious how to perhaps safeguard the flash of false ui as well as avoiding the error
Activity