Files
shlink-web-client/src/common/ScrollToTop.tsx
2022-05-06 20:13:51 +02:00

13 lines
309 B
TypeScript

import { FC, PropsWithChildren, 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}</>;
};