Tankōbon / hooks/use-scroll-to-top-on-navigation / useScrollToTopOnNavigation
Function: useScrollToTopOnNavigation()
useScrollToTopOnNavigation(
ref):void
Defined in: hooks/use-scroll-to-top-on-navigation.ts:13
Puts ref's scroll position back to the top whenever the route's path changes. The root layout's <main> stays mounted across routes, so without this a new page would open at the scroll offset of the previous one. Search parameters don't count: changing them keeps the user where they are.
Parameters
ref
RefObject<HTMLElement | null>
Returns
void