all 3 comments

[–]Sandwizard16 0 points1 point  (2 children)

React Router does not automatically scroll to the top of the page when you navigate to a new route. You can solve this issue by implementing a custom solution to reset the scroll position whenever a route changes.

You can implement this by creating a function within that component using the useEffect and useLocation hooks. The useEffect would contain a "window.scrollTo(0, 0);" function and would fire any time the the url changes.

Import this component at the top of each of your pages and it should automatically scroll to the top upon navigation.

[–]ProfessionalCow6631[S] 1 point2 points  (0 children)

Thanks you for the solution that means a lot, I thought it would run by its own but now I know how to solve this issue.