department-of-veterans-affairs/vets-website

View on GitHub
src/applications/verify-your-enrollment/hooks/useScrollToTop.js

Summary

Maintainability
A
0 mins
Test Coverage
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export const useScrollToTop = () => {
  const { pathname } = useLocation();

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