-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[added] wraptag property for Link #816
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
Conversation
Have you considered using react-router-bootstrap with react-bootstrap instead? |
My personal opinion is that |
@krawaller I agree with @gaearon. I'd like to keep |
Yeah, I guess you guys are right. It just feels a bit... inelegant to have My reasoning was that since using a property is cognitively much cheaper than creating a component + importing a mixin + making the isActive call + adding the classes, the difference in cost warranted the API bloat. But I might be overestimating how common the wrapping need actually is, and either way, you are probably right to demand an even higher price for increasing API complexity. Well done, you passed the test! ;) |
Personally I don't see adding a component in the consuming app as a cost. I wrap most of the components from other libraries, whether it's a This also gives you greater flexibility when changing tools. For example, I had a custom |
I meant it as a cognitive cost, i.e. how hard it is to figure out. But that was a really silly reasoning to begin with, as the ability to create components is definitely something you can assume in a user of this library. :P |
What about allowing the link component itself to be customized like Ember does it: <Link component="li" to="..." /> This would allow us to do whatever we want. |
This is deliberately a |
ok, sure. I'm not looking for compatibility with React-Bootstrap but I do need the same functionality as krawaller was asking for. It seems like I have to create my own wrapper component using a mixin which is fine however, that's a tough thing for a new comer to wrap their head around. Especially without knowing there's a state mixin which can help with that. I think adding an example to the repo showing how to accomplish this would help a lot of people, myself included. |
You can quite possibly just use the React-Bootstrap wrapper. It's fairly generic. |
I'm not interested in using that library, I just want to keep things simple. After browsing through the react-router code base it appears that the State mixin isn't a thing anymore. Anyone willing to provide a gist on how to create a simple wrapper for Link which applies an active class as discussed in this thread? I'm using ES2015 (ES6) |
React-Router-Bootstrap is literally two wrapper components and has no dependency on React-Bootstrap at all. You can reinvent as much or as little as you'd like. I'm not interested in continuing this conversation. |
@taion Thanks for the help. Maybe you didn't realize that your second last comment referred me to react-bootstrap, not react-router-bootstrap. I missed that in one of the initial comments as well. No need to respond to this one... |
Since it is a very common use case to want the
active
class of aLink
to be applied to the parent tag for Bootstrap compatibility, this PR adds a new optionalwraptag
prop toLink
. If supplied, the link will be wrapped in the given tag, and the class names applied to the wrapper instead of the anchor tag.That means I can now do this:
instead of having to make my own wrapper component, looking something like this: