Skip to content
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 ignores search params if url ends with hash-link #11343

Open
segnord opened this issue Mar 13, 2024 · 0 comments
Open
Labels

Comments

@segnord
Copy link

segnord commented Mar 13, 2024

What version of React Router are you using?

6.17.0

Steps to Reproduce

Consider url http://localhost:3000/?location=xx&room=yy#/view

The hook can't see parameters when the broser api url.searchParams can parse them.

note: everything is ok for http://localhost:3000/#/view?location=xx&room=yy

Expected Behavior

http://localhost:3000/?location=xx&room=yy#/view

const [searchParams] = useSearchParams();
console.log(searchParams.has("room"))
// returns TRUE

const url = new URL(window.location.href);
console.log(url.searchParams.has("room"))
// returns TRUE

Actual Behavior

http://localhost:3000/?location=xx&room=yy#/view

const [searchParams] = useSearchParams();
console.log(searchParams.has("room"))
// returns FALSE

const url = new URL(window.location.href);
console.log(url.searchParams.has("room"))
// returns TRUE
@segnord segnord added the bug label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant