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

Query string is returned twice when it has spaces in it #798

Open
selbekk opened this issue Jun 3, 2020 · 2 comments
Open

Query string is returned twice when it has spaces in it #798

selbekk opened this issue Jun 3, 2020 · 2 comments

Comments

@selbekk
Copy link

selbekk commented Jun 3, 2020

I opened this issue in the React Router repo first, but it looks like the issue might be rooted in this package.

Reproduction
https://codesandbox.io/s/lively-bash-4vmb6?file=/src/App.js

Steps to reproduce
Replace the search string with something with a space in it. In my example you do that by clicking the button

Expected Behavior
I'd expect the search parameter to resolve to the decoded string right away.

Actual Behavior
The search parameter first returns the encoded version of the space (so for%20example in my repro), and then immediately changes to for example.

I'm using the search parameter to trigger a useEffect (which in turn calls our API), so this kind of blows 😅

Any idea as to why this is happening?

@vivekkhatri
Copy link

Hey @selbekk I'm new to React but I've found something. Kindly let me know how we should communicate.

@mjackson
Copy link
Member

Hmm, it looks like the double render could be a hash history bug. The hashchange event sometimes fires multiple times in quick succession, so there is some code in createHashHistory that tries to prevent from firing the listener multiple times. But in this case since the query string is apparently changing I bet it's firing once for each encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants