Could you please help me to understand why active style is all the time active? I've got "react-router-dom": "^6.1.1". I tried different variety of way to apply this stylies the way it's written in react router documentation, but still i can't find the mistake why it is so.
import { NavLink } from "react-router-dom";
import s from "../Sidebar/Sidebar.module.css";
function Sidebar() {
return (
<div className={s.Sidebar}>
<NavLink
to="/profile"
style={(isActive) => ({ color: isActive ? "green" : "blue" })}
className={s.navItems}
>
Profile
</NavLink>
<NavLink
to="/messages"
style={(isActive) => ({ color: isActive ? "green" : "blue" })}
className={s.navItems}
>
Messages
</NavLink>
<br />
</div>
);
}
export default Sidebar;
.navItems{
display: flex;
text-decoration: none;
font-size: 26px;
padding-bottom: 8px;
}
[1]: https://i.stack.imgur.com/cCsBw.png