Skip to content
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 function to <Link />'s attributes #2255

Closed
srph opened this issue Oct 13, 2015 · 2 comments
Closed

Allow function to <Link />'s attributes #2255

srph opened this issue Oct 13, 2015 · 2 comments

Comments

@srph
Copy link

srph commented Oct 13, 2015

Here's a basic idea:

<Link
  to={({ location, routeParams /*, ...otherRouterStuff */ }) => `posts/${routeParams.id}?search=${location.query.q}`}
  query={({ location }) => ({ ...location.query, search: 'yolo' })} />

For some reason, I just find it tedious passing down the location prop (from the router handler/component) 3~5 levels just for some link. Or maybe I'm just doing the Smart and Dumb Component pattern poorly.

@knowbody
Copy link
Contributor

you can just use context, something like: this.context.location

@taion
Copy link
Contributor

taion commented Oct 15, 2015

Please correct me if I'm wrong, but I think functionally you're looking for something like #2172?

Otherwise as @knowbody said, you can get location from this.context.location, though not so much params - see #2278.

I'm going to close this for now unless you think there are concerns not addressed by those.

@taion taion closed this as completed Oct 15, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants