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
[Bug]: setSearchParams() from useSearchParams() can add trailing slash to pathname in some circumstances #8312
Comments
Just encountered the same behavior with version 6.2.1. After short digging, I've found the cause in |
Created CodeSandbox for this: https://codesandbox.io/s/react-router-issue-8312-63qqc7 |
This should be fixed by #8861 - this should be included in the next |
What version of React Router are you using?
6.0.2
Steps to Reproduce
With a BrowserRouter configured with a basename of
/foo/bar
and the browser pointed atsite.com/foo/bar
, use thesetSearchParams
function returned by theuseSearchParams()
hook to set search parameters such as:setSearchParams({ name: 'Bob' })
Expected Behavior
The browser URL should update to
site.com/foo/bar?name=Bob
Actual Behavior
The browser URL updates to
site.com/foo/bar/?name=Bob
Note the trailing slash at the end of the path.
The text was updated successfully, but these errors were encountered: