rafgraph / react-router-hash-link

Hash link scroll functionality for React Router
https://react-router-hash-link.rafgraph.dev
MIT License
732 stars 62 forks source link

React router v6 support #86

Closed charlesomer closed 3 years ago

charlesomer commented 3 years ago

Hi,

Just wondered if it's possible to use this with React Router V6 or if it's been tried?

Thank you Charles

rafgraph commented 3 years ago

I haven’t tried it yet. I’m sure others are curios too. If you try it let us know if it works!

charlesomer commented 3 years ago

Hmm I'm not completely sure how to test it, trying to just install the module fails because it doesn't recognise the beta release of React Router. I tried cloning and importing manually but it wasn't happy about that either 😂

charlesomer commented 3 years ago

Never mind, forgot about --force. Managed to get it installed and it seems to work okay!

charlesomer commented 3 years ago

On a slightly separate note, is it possible to scroll to top automatically if no # is present in the link?

rafgraph commented 3 years ago

Great, glad it works!

To scroll to top without # or #top you’ll need to do this manually in your onClick handler.