Earlier quoted context omitted.
> The solution to the external links issue is a one-liner. It is most definitely not a one-liner. > Making the page scroll to the top when navigating to a new page is trivial. So do it for me. There’s no reason a routing library should break default behavior. > That's exactly what it's supposed to do. It's a client side routing solution. (I'm also pretty sure that it doesn't remount) Then it’s “supposed” to have inco…
> So do it for me. I think this will work: Put this wherever you put your reusable functions: `const scrollToTop = () => document.getElementById('root').scrollIntoView();` And put this in the components / functions you want the scrollToTop effect to work on: `useEffect(() => { scrollToTop() }, []);` And put this in your CSS: `html { scroll-behavior: smooth }` (Edit to add: Not saying React Router is something you sho…
A full solution is a little more tricky, and probably involves code on multiple components:
- You'll need something to scroll to the top or the current hash on load - You'll also need code on components to check if they link to the current URL/hash, and if they're pointing to the current hash, you'll need to scroll to it on click.
Here's some relevant scroll management code from Navi's components:
- https://github.com/frontarm/navi/blob/master/packages/react-...
- https://github.com/frontarm/navi/blob/master/packages/react-...