-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link activeClassName not being applied for dynamic routes #3286
Comments
Btw, I also submitted this question on reactiflux#react-router channel, no one has responded yet, most discussion seems to be around |
<Link>
's activeClassName not being applied for dynamic routes
We have such tests for |
@musbaig we can't really diagnose the problem without a test case, mind tossing one up on jsbin, codepen, a github repo, or a unit test in this project? |
After fighting with this for several days, I finally figured out the root cause of the problem. |
@taion oh wow, that's cooool, great tip, thank you soo much for following up!! Works perfectly, feels more natural and a lot less hacky, cheers! |
Perfect, this solved a similar problem with For newcomers, see documentation on |
@laustdeleuran That link should be somewhere in the Anyways, thanks so much for the link. I am a noob to redux and react-router and this helped me immensely. |
@aleccool213 yeah, I'm pretty new at this too, and the documentation is not that easy to find your way around in. Spent some time looking for this too, before I found this thread. |
This is fixed in React Router |
Here is the issue I'm seeing. I have a typical navbar with several
<Link>
s linking to dynamically loaded (routed) components (Routes). Code-splitting for the dynamic routes is being handled with webpack and I'm also using react-router-redux to sync route state with my Redux store. (All deps are latest/greatest).Now if I click on one of the links, the correct route is loaded, however, the
<Link>
'sactiveClassName
isn't applied. Clicking the link a second time, however, now applies the active class.I'm wrapping
<Link>
in another component for styling purposes, and as such have tried usingthis.context.router.isActive(...)
; again, active styles and/or isActive flag are only triggered after the second click, not sure what is going on. Is this a bug inreact-router
? Any help would be greatly appreciated.Note: this is only an issue with dynamic routes, if I were to turn them to a static ones, everything works as expected.
The text was updated successfully, but these errors were encountered: