react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Bug]: setSearchParams from useSearchParams remove hash

Open MariusJam opened this issue 7 months ago • 0 comments

What version of React Router are you using?

6.22.3

Steps to Reproduce

  1. Navigate to a page and add a hash to the url
  2. 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.

MariusJam avatar Jul 10 '24 14:07 MariusJam