react-scroll
react-scroll copied to clipboard
How to scroll with hash? Example is empty
I'm trying to learn how to push the target to the url when I click an element, so the webpage can also scroll to the right element when the hash is in the url... I think I can achieve this by using the hash, but the example is showing up with a blank sandbox...
https://codesandbox.io/s/y0zzrk1v1j
Any ideas on how to achieve this?
I'm using Gatsby
Any update on this? Would be useful... It's probably not very hard to code myself, but there should be a way to do it with this package, no?
Hi,
There is an example section in the repo.
https://github.com/fisshy/react-scroll/tree/master/examples/with-hash
Any chance to get a codesandbox.io link for this? Considering the one in the documentation is dead...
I tried it out in the "basic example" sandbox.io page because that seems to contain an anchor link as well and it doesn't work. My expectation is that when I open the page with a hash URL parameter (i.e. web.site/subpage#anchor
), the page is scrolled to the section with the ID anchor
. That doesn't work for me.
https://codesandbox.io/s/basic-forked-8jje2?file=/src/index.js
I created one simple here for you.
I see, thanks. The important part is giving the ID to a standard <div>
instead of an <Element>
, then it works.