I am looking to update the navbar color upon scrolling using the useState hook.
const Navbar = () => {
const [colorChange, setColorchange] = useState(false);
const changeNavbarColor = () =>{
if(window.scrollY >= 38){
setColorchange(true);
}
else{
setColorchange(false);
}
};
console.log(setColorchange)
window.addEventListener('scroll', changeNavbarColor);
I need help figuring out how to control the background property of the styled component below using state.
const NavbarContainer = styled.div`
width: 100%;
height: 38px;
background-color: red;
margin-top: 10px;
display: flex;
justify-content: space-between;
position: sticky;
top:0;
z-index: 1;
`;