react-router
react-router copied to clipboard
[Bug]: setSearchParams from useSearchParams remove hash
What version of React Router are you using?
6.22.3
Steps to Reproduce
- Navigate to a page and add a hash to the url
- Call setSearchParams to add some query params to the url
Example available here: https://stackblitz.com/edit/github-zuy2xj?file=src%2Fapp.tsx
Expected Behavior
Both the hash and query params should be in the final URL. As stated in react-router documentation "The useSearchParams hook is used to read and modify the query string in the URL" so, the hash in the URL should not be impacted.
Actual Behavior
Query params are in the url but the hash is completely removed.