Reputation: 503
React router V4.2 does not get the visited style
const activeLink = {
"color": "red"
}
<Link to="/" activeStyle={activeLink}>
All categories
</Link>
I have tried with to, but no success
Upvotes: 2
Views: 70
Reputation: 112787
The Link
component doesn't have activeStyle
, but the NavLink
component does.
<NavLink
exact
to="/"
activeStyle={{ color: "red" }}
>
All categories
</NavLink>
Upvotes: 2
Reputation: 503
Problem solved, tnx 1. it must be but not 2. exect={true} is mandatory
Upvotes: 0
Reputation: 2200
Seems that Link doesn't support this property.
You may want to try NavLink:
React Router Documentation: A special version of the that will add styling attributes to the rendered element when it matches the current URL
For more info: https://reacttraining.com/react-router/web/api/NavLink
Upvotes: 1