React-router: NavLink should have an exact prop

Created on 31 Jan 2017  路  2Comments  路  Source: ReactTraining/react-router

Hi,

I just updated to the beta of react-router v4. I found out about the NavLink component by looking at the code, it's not present in the documentation.

It works quite well, except when I want to use it in a navbar for nested routes, because the NavLink apply the active class if the url match partially and not exactly, it leads to multiple NavLink in my navbar having the active class at the same time.

What do you think about adding a prop to control this behavior ?

Thanks !

Most helpful comment

Thanks for your reactivity ! The work on documentation is amazing ;)

All 2 comments

I found out about the NavLink component by looking at the code, it's not present in the documentation.

:( Sorry about that. We've done a ton of work on the docs, but there's still a ton to do. Also please keep in mind this is still a beta release.

On the bright side, you probably caught a glimpse of how easy it is to compose <Route> and <Link> together to create <NavLink> by looking through the source ;)

But you're right, <NavLink> should probably have both exact and strict props, just like <Route> does, to expose the full variety of matching options.

Thanks for your reactivity ! The work on documentation is amazing ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

misterwilliam picture misterwilliam  路  3Comments

maier-stefan picture maier-stefan  路  3Comments

sarbbottam picture sarbbottam  路  3Comments

ackvf picture ackvf  路  3Comments

stnwk picture stnwk  路  3Comments