-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Experimental basePath history defects and some feedback #10493
Comments
We have a similar issue with Dynamic Routes, when using basePath and try to navigate with the back and forward button on the browser. Scenario 1 Works! :
Scenario 2: Fails! :
|
Another issue ( I think it is the same issue):
|
Linking #9988
Feel free to reach out to enterprise@zeit.co and we can see if it's possible to help you out on a shorter time-frame. |
This comment has been minimized.
This comment has been minimized.
This behavior should be fixed as of 9.3.5! |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
Firstly, thank you to @timneutkens for #9872 .
I appreciate that we should probably not be using an experimental feature in production but unfortunately we have to use
basePath
despite its experimental flag. We cannot ship our app without an Apollo Client cache. And withoutbasePath
every page is treated as a hard reload of the app, breaking our cache.We have been using
basePath
since its release in9.2.1
and it has fixed almost all our problems.However we just recently discovered quite a major issue with the browser back + forward buttons.
While I was investigating this issue, I uncovered quite a few inconsitencies with basePath and the Link component , compared to using the
Router
directtly.I would imagine a lot of these issues will be resolved by #9988 but I thought I would create this thread to document some of them just incase.
And of course my primary reason is to report the issue with the browser history when using basePath.
To Reproduce
I have created a reproduction repo to assist with this bug report. So clone the repo and open the
Header.js
file.I have commented this file to take you along the reproduction of 2 issues. So the code is probably the best place to start, but I will document them here as well.
Minor inconsistency
The first defect is the inconsitency between the following:
and
Assuming a
basePath
of/test/prefix
the former produces the following route:It seems to leave out the preceding slash
Wheras the latter performs the route (with a hard reload of the page)
Issue with Browser back/forward
To re-iterate our main problem here:
basePath
of/test/prefix
/
Router.push('/page/[id]', '/page/1', { shallow: true })
This is seemingly the only way to prevent a page refresh when routing with basePath. And this is form we use throughout our app./test/prefix/page/1
as expected./test/prefix
as expectedas
value (/test/prefix/page/1) is incompatible with thehref
value (/page/[id]).This is very strange to me, it seems that despite our
Router.push
call excluding thebasePath
- the entry in the history must have been set to include the `basePath.Expected behavior
I would expect when hitting the browser forward button that next executes:
ie. it performs the same
push
call that was originally used.System information
The text was updated successfully, but these errors were encountered: