React-router: How can I follow a Link without it being pushed to history, and preserve URL change?

Created on 15 Dec 2014  路  3Comments  路  Source: ReactTraining/react-router

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?

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 馃槝)

All 3 comments

<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 馃槝)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wzup picture wzup  路  3Comments

davetgreen picture davetgreen  路  3Comments

winkler1 picture winkler1  路  3Comments

jzimmek picture jzimmek  路  3Comments

ryansobol picture ryansobol  路  3Comments