-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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]: useSearchParams hook removes path name from url #9045
Comments
Thanks for the reproduction! Looks like this busted with #8861 - digging in now 👍 |
Fixed in #9048 - should have a |
Still have this issue in 6.4.0-pre.9 for a |
@jrmyio would you be able to provide a simple code sandbox reproduction to demonstrate the issue? |
Just tried to replicate it in a codesandbox but couldn't reproduce. Tomorrow I will try to see what makes my project's context break it. Edit: Found the reason for my issue but it is not a bug in react-router. In the code I assumed |
What version of React Router are you using?
6.4.0-pre.8
Steps to Reproduce
Sandbox demonstrating the unexpected behavior could be found below
https://codesandbox.io/s/boring-banach-ri3tiv?file=/src/App.js
The behavior is erratic only if I have a
basename="assets"
as a BrowserRouter Prop. If I remove thebasename
prop, normal functionality is restoredExpected Behavior
When I do setSearchParams( {foo:'bar'} ) when on url path
basename/id1
, the url should get changed tobasename/id1?foo=bar
Actual Behavior
When I do setSearchParams( {foo:'bar'} ) when on url path
basename/id1
, the url is changed tobasename?foo=bar
For eg, in the sandbox:
https://codesandbox.io/s/boring-banach-ri3tiv?file=/src/App.js
Sandbox Steps:
/assets
Click on the button 'Click me!'Notice how the url changes to assets?buttonone=test and not assets/id1?buttonone=test
The text was updated successfully, but these errors were encountered: