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

push() and replace() will keep current search and hash string #814

Open
yangmingshan opened this issue Jul 8, 2020 · 6 comments
Open

push() and replace() will keep current search and hash string #814

yangmingshan opened this issue Jul 8, 2020 · 6 comments

Comments

@yangmingshan
Copy link

When
Current location is http://localhost?a=a#b

Do

history.push('/');
// OR
history.replace('/');

Expect
Location change to http://localhost

Actual
Location still is http://localhost?a=a#b

@chaurunda
Copy link

Got the same issue

@jnields
Copy link

jnields commented Aug 7, 2020

Yeah, this definitely seems like a bug to me too as it's a breaking change that is not documented with the 5.0.0 release, and just feels very unintuitive.

https://github.com/ReactTraining/history/releases/tag/v5.0.0

@GordonSmith
Copy link

GordonSmith commented Aug 11, 2020

I think what I am seeing the same issue, but with "createHashHistory":

  1. My URL is: http://localhost:8080/esp/files/index.html#/main?lastNDays=31&protected=false&state=completed
  2. The user hand edits the URL in the address bar to: http://localhost:8080/esp/files/index.html#/main?lastNDays=999&protected=true
  3. In history.listen I still get: ?lastNDays=31&protected=false&state=completed for the search...

@Hypnosphi
Copy link

Here's my workaround:

const push = (to, state) => history.push({
  hash: '',
  search: '',
  ...(typeof to === 'string' ? parsePath(to) : to)
}, state)

@zhangdingding
Copy link

It looks more like a bug than a feature 🤔

@unbugx
Copy link

unbugx commented Jan 15, 2021

same is here #808

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

No branches or pull requests

7 participants