import { useEffect, useRef } from 'react'; export default function useScrollIntoView(name: string, location?: string) { const ref = useRef(null); useEffect(() => { if (location && ref.current) { if (location === name) { ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } }, [location, name]); return ref; }