#NavLink optional route parameter

1 messages · Page 1 of 1 (latest)

jolly tinsel
#

Having a function that defines the "active state" of a <NavLink />
or the ability to make route:

/workspace/15/item4 also be marked as active on /workspace/15

outer patio
jolly tinsel
sharp tinsel
#

Did you try using the “end” prop?

jolly tinsel
#

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)