some-react-components / react-scrollchor

A React component for scroll to `#hash` links with smooth animations
ISC License
149 stars 24 forks source link

When the target element is missing, Scrollchor throws a TypeError #10

Closed guncha closed 7 years ago

guncha commented 7 years ago

This doesn't match the behavior of the native anchor links that simply update the URL, but don't do anything else if the anchor is not found on the page.

bySabi commented 7 years ago

That's correct. Scrollchor try to be more API friendly than <a> spec compliant. At API level do nothing is like fail silently.

Why do you need match native anchor?

guncha commented 7 years ago

Oh, I just had an issue where the user can click on a link while the page is still loading and the error thrown caused the error page to be rendered instead. I wrote a quick implementation to do the same, but fail silently so it's ok. This is up to personal preference, I guess.