shlink-web-client/src/common/ScrollToTop.tsx
2023-02-18 10:40:37 +01:00

14 lines
338 B
TypeScript

import type { FC, PropsWithChildren } from 'react';
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
export const ScrollToTop: FC<PropsWithChildren<unknown>> = ({ children }) => {
const location = useLocation();
useEffect(() => {
scrollTo(0, 0);
}, [location]);
return <>{children}</>;
};