Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I follow a react-router Link without it being pushed to history, but keep URL change?

I want to change URL when 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 in this answer:

this.props.activeRouteHandler({key: "anystring"})

but I don't know where should I place it and if it even works anymore. Can someone give me an example? Thanks

like image 977
Radivarig Avatar asked Oct 27 '25 03:10

Radivarig


1 Answers

Use the replace property of Link and set it to true.

Here is a link to the documentation: https://reactrouter.com/web/api/Link

ex.

<Link to=[your_url] replace={true}>
  ...
</Link>
like image 59
Marko Rochevski Avatar answered Oct 29 '25 09:10

Marko Rochevski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!