i want to change color of the active nav link in react

const Navbar = () => {

const {pathname} = useLocation();

return (

<ul id="navigation">
<Link to="/" className={(pathname === '/') ? 'active' : ''}><li>Home</li></Link>
<Link to="/about" className={(pathname === '/about') ? 'active' : ''}><li>About</li></Link>
<Link to="/service" className={(pathname === '/service') ? 'active' : ''}><li>Service</li></Link>
</ul>;
)
const Navbar = () => {

const {pathname} = useLocation();

return (

<ul id="navigation">
<Link to="/" className={(pathname === '/') ? 'active' : ''}><li>Home</li></Link>
<Link to="/about" className={(pathname === '/about') ? 'active' : ''}><li>About</li></Link>
<Link to="/service" className={(pathname === '/service') ? 'active' : ''}><li>Service</li></Link>
</ul>;
)
} is this method fine ?
1 Reply
glutonium
glutonium3mo ago
looks good
Want results from more Discord servers?
Add your server