-
Notifications
You must be signed in to change notification settings - Fork 158
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
NavItem active w/ LinkContainer #193
Comments
don't set |
@taion So I tried using the |
I believe @taion is saying, don't use |
@jquense Thanks for the advice. So I changed my code to look like this;
This is causing both I also found this thread that mentions documentation for RRC? Does RRC stand for |
Don't use |
So it's keeping both active still in this example. Can we not do
|
That's how React Router active semantics work. They only look at the path. |
So that's why I'm doing logic to look at the I'm just thinking it makes sense to look at the |
This package is just an integration. That sort of extra functionality doesn't belong here. |
@taion Jimmy, could you please post an example showing your idea? According to the three answers above, I have yet figured out how I should use this library as my navigation bar. |
@pmcavoy89 I'm using URL hashes and I got it to work correctly by using exact on the LinkContainer. |
@ddelrio1986 Can you provide an example? And what versions of |
@pmcavoy89 I'm using react-router-bootstrap v0.24.4 and react-router v4. It's works for me: |
@Susa70 Can you please provide the exact version of react-router, I am using 4.3.1 and it is not working for me. |
@pmcavoy89 sorry I did not see your reply above before. I am searching for the example as I no longer have it and it is lost in the git history somewhere. I can confirm that I was using react-router 4.2.1 and react-router-bootstrap 0.24.4 at that time though. |
Now I am using the IndexLinkContainer component a lot since it automatically includes the exact for me: https://github.com/react-bootstrap/react-router-bootstrap/blob/master/src/IndexLinkContainer.js |
I had a similar issue. adding I had: <LinkContainer to="/">
Home Link
</LinkContainer>
<Nav activeKey="/">
<LinkContainer to="/buy">
<Nav.Link>buy</Nav.Link>
</LinkContainer>
<LinkContainer to="/rent">
<Nav.Link>rent</Nav.Link>
</LinkContainer>
</Nav> so that my "/" link was outside of |
The problem is that the
<LinkContainer />
has the propactiveKey
but myNavItem
has a prop foractive
true for bothNavItems
.Example:
Both
<LinkContainer />
s have theprop.activeKey
of theselectedTab
. Once I take the<LinkContainers />
off I get the active working properly. The thing is that it doesn't update my route then. I've also tried using theactiveHref
prop and that doesn't seem to help.A hack that I've used to get around this issue was this;
This seems a little hacky and I feel like the
<LinkContainer />
is wrapping the<NavItem />
so that the<Nav />
can't grab the right component to calculate theactiveKey
. Or am I just missing something here?The text was updated successfully, but these errors were encountered: