'is there a way to implement react scroll along with react router dom?

I have a navbar with links that scroll to sections of page using react-scroll. i also have several pages and im using react-router-dom for navigating between pages. but when i click on the links in navbar when on a different page, it says element not found. so i wrapped the link in Navlink from react-router-dom. now this works as i want it but on a different page when i want to switch pages, it takes a lot of time to render the switched page. almost like 2-3 seconds. and if i dont use react-scroll, the pages are rendered instantly.

so is there a way to use react-scroll and react-router-dom without causing this delay?



Solution 1:[1]

there is a youtube tutorial if you would like to have to a look, it build website from scratch using router and react-scroll:


https://youtu.be/Nl54MJDR2p8

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Johan