I have a Header component like this
const [small, setSmall] = useState(false)
console.log(window.location.pathname)
console.log(window.location.pathname === '/')
useEffect(() => {
if (typeof window !== "undefined") {
if(window.location.pathname === '/'){
window.addEventListener("scroll", () =>
setSmall(window.scrollY > 640),
);
}
}
}, []);
html:
<nav className={`padding-280px ${ small ? "colorful" : "transparent"}`}
the problem is that when am on different Route, console says false, but Header component changes anyway. any tips?