const [scroll, setScroll] = useState(false); useEffect(() => { window.addEventListener("scroll", () => { setScroll(window.scrollY > 50); }); }, []);