question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`push()` and `replace()` will keep current `search` and `hash` string

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:30
  • Comments:6

github_iconTop GitHub Comments

5reactions
Hypnosphicommented, Sep 4, 2020

Here’s my workaround:

const push = (to, state) => history.push({
  hash: '',
  search: '',
  ...(typeof to === 'string' ? parsePath(to) : to)
}, state)
4reactions
arnaudhuccommented, Jul 20, 2020

Got the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Share a link to this question - Stack Overflow
According to the docs: · length - (number) The number of entries in the history stack · action - (string) The current action...
Read more >
History - React Router: Declarative Routing for React.js
The term “history” and " history object" in this documentation refers to the history ... action - (string) The current action ( PUSH...
Read more >
Using React with the History API - Pluralsight
action - (string) The current action ( PUSH , REPLACE , or POP ) ... goForward() - (function) Equivalent to go(1).
Read more >
History.pushState() - Web APIs | MDN
pushState() method adds an entry to the browser's session history ... only creates a new history entry if the current hash isn't #foo...
Read more >
react-router: useHistory, useLocation and useParams
.replace(pathname: string, state: any)/(location: object): this is basically similar to push, but it will remove the existing history and update ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found