7

Using React Router, what's the best way of pushing a new entry to the history so it updates the URL, but without triggering a new route?

The Navigation.replaceWith() mixin method seems to do the opposite of what I need.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
evilcelery
  • 15,941
  • 8
  • 42
  • 54

1 Answers1

3

Not really familiar with React-Router's API, but you could use pure javascript to do that.

window.history.pushState({}, '', 'https://stackoverflow.com/new-url-here');

More answers here: Modify the URL without reloading the page

Community
  • 1
  • 1
Maktouch
  • 3,117
  • 20
  • 21