"use client";

import { useEffect } from "react";

export function HashScroll() {
  useEffect(() => {
    const scrollTarget = sessionStorage.getItem("scrollTo") || window.location.hash.replace("#", "");
    if (scrollTarget) {
      sessionStorage.removeItem("scrollTo");
      const el = document.getElementById(scrollTarget);
      if (el) {
        setTimeout(() => el.scrollIntoView({ behavior: "smooth" }), 500);
      }
    }
  }, []);

  return null;
}
