Add the isNavLinkActive helper function #10748
lukejagodzinski
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, currently
NavLink
supports passing function to theclassName
prop so that we can style link differently depending onisActive
/isPending
state. TheclassName
property is not the only place where it's handy. For example, I want to scroll to the active link after tab refresh. I know there are other ways to do that with refs and some tricks but it would be nice to have the same functionality in theautoFocus
property. However, just to not override all the props for the anchor tag, I would just suggest adding a utility function. I can create my own but would be great to have something built in.One benefit would be for the future to actually not use
<NavLink>
element at all and just use pure<a>
. I've read somewhere that that there was a proposal of attaching single events to all the links on the page and intercepting all the links' clicks.Basically I would like to do something like:
Wdyt?
Beta Was this translation helpful? Give feedback.
All reactions