import { FC, ReactNode, useEffect } from "react";
import { useLocation } from "react-router-dom";

interface IProps {
  children: ReactNode;
}

const ScrollToTop = ({ children }: IProps): any => {
  const location = useLocation();
  useEffect(() => {
    window.scrollTo({
      top: 0,
      behavior: "smooth",
    });
  }, [location.pathname]);

  return children;
};

export default ScrollToTop;
