/**
 * @fileoverview Component to scroll to top on route change
 * 
 * @module components.ScrollToTop
 */

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

/**
 * Component that scrolls window to top whenever the route changes.
 * Must be placed inside Router.
 */
export default function ScrollToTop() {
  const { pathname } = useLocation();

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);

  return null;
}
