"use client"; import { useCallback, useEffect, useState } from "react"; export function useScroll(threshold: number) { const [scrolled, setScrolled] = useState(false); const onScroll = useCallback(() => { setScrolled(window.scrollY > threshold); }, [threshold]); useEffect(() => { window.addEventListener("scroll", onScroll); onScroll(); return () => window.removeEventListener("scroll", onScroll); }, [onScroll]); return scrolled; }