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;
