Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Router: Add entry to history without changing route

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.

like image 784
evilcelery Avatar asked Oct 31 '22 09:10

evilcelery


1 Answers

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

like image 132
Maktouch Avatar answered Nov 07 '22 22:11

Maktouch