This was pretty simple in Vanilla JS but I'm struggling to implement this in React.
I have Navbar with some links. Upon hovering over each link, I'd like the background color of the entire Navbar (classname: nav-section) to change accordingly. And by default I want to have a black color for the page. Anytime the cursor is not on any of the links, the navbar should be back to black again.
Say, my simplified Navbar.js is like this:
const Navbar = () => {
return (
<nav className='nav-section'>
<div className="nav-list">
<a className="list-item one">
<div className="navlink-text">Red</div>
</a>
<a className="list-item two">
<div className="navlink-text">Blue</div>
</a>
<a className="list-item three">
<div className="navlink-text">Aqua</div>
</a>
<a className="list-item four">
<div className="navlink-text">Cyan</div>
</a>
</div>
</nav>
);
};
export default Navbar;
I have an external css file styling the navbar and other elements that I have in it. What is the most efficient way to achieve what I want, with React? I tried to use emotion/css but I couldn't make it work. Any guidance is well appreciated.