-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Allow <Link to>
to be a function
#3657
Comments
This is really good feature! But what about |
This is awesome |
I would like to propose also a possibility to provide a function to set isActive flag. Something like <Link to="/hello" isActive={location => location.pathname === '/hello'} activeClassName="active"> |
@jodo4x Where do you get pathname from? |
@jodo4x yes, but if your component is deeply nested you need to pass location through the components tree. Well this issue is not suited for this discussion. I'll open a separate one. |
Added in #3669 |
Hmm, I wonder if these functions should take e.g. |
I think |
@eldh Thanks for your feedback! How would you use |
The reason I ask is because I can think of a few places where I could use |
Yeah, that would be a common case. We have some places where we do filtering in such a way that it would be a nice addition. Not sure, maybe relative links could solve that too. |
@eldh Can you clarify regarding the filtering use case a bit? Just trying to understand use cases here. I'm really torn here because ({ query, ...location }) => ({ ...location, query: { ...query, new: 'query' } }) but I don't want to rule out real use cases. |
We have some cases where params are part of a (known) set, and to calculate filter options we'd need access to the params. However, I'm not even sure that this api would be the cleanest way to solve that case though. And I suspect we aren't using react-router idiomatically anyway, so feel free to disregard my comments :) |
Okay, I think I'll go with |
Maybe a little QoL, thing... it'd let people do e.g.
without having to worry about having
location
on context or wrapping the<Link>
's parent withwithRouter
.The text was updated successfully, but these errors were encountered: