19 lines
376 B
TypeScript
19 lines
376 B
TypeScript
import React, { ReactElement, useEffect } from 'react';
|
|
import { useLocation } from 'react-router-dom';
|
|
|
|
interface Props {
|
|
children?: React.ReactNode;
|
|
}
|
|
|
|
const ScrollToTop = ({ children }: Props): ReactElement => {
|
|
const location = useLocation();
|
|
|
|
useEffect(() => {
|
|
window.scrollTo(0, 0);
|
|
}, [location]);
|
|
|
|
return <>{children}</>;
|
|
};
|
|
|
|
export default ScrollToTop;
|