I'd need to change the URL for clicking on component Links, same way they currently change by default, but without them being pushed to browser history.
I've found the following working for someone:
this.props.activeRouteHandler({key: "anystring"})
but I don't know where should I place it and if it even works anymore.
Any ideas?
edit:
I found this answer here https://github.com/rackt/react-router/issues/289
Instead of using Router.transitionTo, use Router.replaceWith to replace the current route and not add to the browser's history.
I couldn't find it in docs, can someone post example of usage?
<Link>
will forever follow the behavior of real <a href>
, which don't have this behavior. As @gaearon mentioned, just use Navigation
. You could even make your own <ReplaceLink/>
. Check out how we've implemented <Link/>
.
Landed on this after a Google search for react router link without adding to history
and almost started implementing my own <ReplaceLink>
!
For anyone else coming across this issue first, let me save you some clicks: <Link replace>
is now an official thing.
(Also find it humorous how "forever" is ~2 years in JS land. Sounds about right 馃槝)
Most helpful comment
Landed on this after a Google search for
react router link without adding to history
and almost started implementing my own<ReplaceLink>
!For anyone else coming across this issue first, let me save you some clicks:
<Link replace>
is now an official thing.(Also find it humorous how "forever" is ~2 years in JS land. Sounds about right 馃槝)