#NavLink optional route parameter
1 messages · Page 1 of 1 (latest)
You can pass an active style or classname: https://reactrouter.com/en/main/components/nav-link
I know that, but when setting link to /workspace/15/item4 and moving to /workspace/15/anotherItem it should stay marked as active
by having like an optional parameter /workspace/:workspaceOd/:optionalItemId?
Did you try using the “end” prop?
The end prop would not match /workspace/15/item4/anotherRouteParam when the to prop is set to /workspace/15/item4
I want to have an optional parameter in the to prop to
<NavLink to="/workspace/15/item4" />
but it should stay active when navigating to /workspace/15/anotherItem
basically only /workspace/15 should be considered and /:item? should be optional
I could achieve that with a isActive function and handle it myself (but the has been removed in react-router@6)