NavLink component of react-router-dom package supports adding extra logic for determining whether the link is active. At least this was supported in older version. Here is link to documentation: https://reactrouter.com/web/api/NavLink/isactive-func
Code snippet:
<NavLink
to="/events/123"
isActive={(match, location) => {
if (!match) {
return false;
}
// only consider an event active if its event id is an odd number
const eventID = parseInt(match.params.eventID);
return !isNaN(eventID) && eventID % 2 === 1;
}}
>
Event 123
</NavLink>
It seems like isActive property is not supported anymore in version 6. What are other options to achieve the same thing?