I want to scroll to different parts of my page by clicking, but I don't want the URL to get updated in the address bar.
For example, I have an about
section on my page, with the ID about:
<div id='about'>
By clicking a link on the page, I want to scroll to this section. I've been able to do this with both the <Link>
component, and using the router
, however using both, I haven't been able to do this without updating the URL.
For example, using router
, I would have:
router.replace(`/#about`);
This works fine, except the URL gets updated to myurl.com/#about
, where as I want to keep the URL as myurl.com
.
I've tried using the second as
argument to set the URL, for example:
router.replace(`/#about`, '/');
However, this just breaks the link.
Anyone have an idea how to achieve this without updating the URL? I've found no examples, and nothing useful in the docs.
Thanks to anyone who can help!