Integrates www.gigafibre.ca (React/Vite) into the monorepo. Full git history accessible via `git log -- apps/website/`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
563 B
TypeScript
23 lines
563 B
TypeScript
import { useEffect } from "react";
|
|
import { useLocation } from "react-router-dom";
|
|
|
|
export const ScrollToTop = () => {
|
|
const { pathname, hash } = useLocation();
|
|
|
|
useEffect(() => {
|
|
if (hash) {
|
|
// Delay to ensure DOM is rendered before scrolling to hash
|
|
setTimeout(() => {
|
|
const el = document.querySelector(hash);
|
|
if (el) {
|
|
el.scrollIntoView({ behavior: "smooth" });
|
|
}
|
|
}, 150);
|
|
} else {
|
|
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
}
|
|
}, [pathname, hash]);
|
|
|
|
return null;
|
|
};
|