You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a feature request concerning <Link> API. My typical use case is that I want to have buttons to pass query parameters, but stay on the same page. Then, I was thinking of doing something like
<Link to={{ query: { page: 1 } }}
But it does not work because Link component expects to have a pathname value.
My problem is then that I have to do something like
but that I have to fetch the currentPath from somewhere. If I was in a Route component, I could just fetch this.props.location.pathname, but this is not my case, and I am in an included components, some levels deep.
I thought about using the context injection, but the injected object does not offer any possibility to retrieve current pathname apparently.
So, my feature request is to either allow a Link without pathname, and then defaults the pathname to the current pathname, or provide a way to access current pathname outside of props. Indeed, as of now, the only solution I could find is to pass the location props down to every component, which is quite verbose, especially since I only need it in a single component downwards.
Thanks!
The text was updated successfully, but these errors were encountered:
You spread in the old location – { ...location, query: newQuery }. If we go ahead with #3657 it will be even easier.
We don't really want to do this at the level of <Link> like this directly because the object spread syntax is just as terse but gives you more direct control over how you build the new location.
Hi,
I have a feature request concerning
<Link>
API. My typical use case is that I want to have buttons to pass query parameters, but stay on the same page. Then, I was thinking of doing something likeBut it does not work because
Link
component expects to have apathname
value.My problem is then that I have to do something like
but that I have to fetch the currentPath from somewhere. If I was in a
Route
component, I could just fetchthis.props.location.pathname
, but this is not my case, and I am in an included components, some levels deep.I thought about using the context injection, but the injected object does not offer any possibility to retrieve current
pathname
apparently.So, my feature request is to either allow a
Link
withoutpathname
, and then defaults the pathname to the current pathname, or provide a way to access currentpathname
outside ofprops
. Indeed, as of now, the only solution I could find is to pass thelocation
props down to every component, which is quite verbose, especially since I only need it in a single component downwards.Thanks!
The text was updated successfully, but these errors were encountered: