-
Notifications
You must be signed in to change notification settings - Fork 147
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
[feature request] Add 'params' prop to the 'A' component #216
Comments
Interesting take. I was working on named routes implementation these days and was looking for a interpolable API. The alternative API is exactly what I came up as well. the object is a "find a match" description. It could precise name, path and/or params, making it very flexible, as well as it allows to easily pass a link reference without API split. So I am +1 on thi solution :) We could also leave declare function buildUrl(query: RouteQuery): string; that could be even more flexible and non-locking option We would need to expose then 2 functions from the router API.
|
What I like about having a separate <A href={routes.user} /> to <A href={routes.user} params={{ id: userId }} /> and vice versa. useMatch('/users/:id', { params: { id: userId }}) |
Yes, that's exactly what we need. The same way, we could have Having this API would even allow to build named routes on top. Im wondering if it would be possible to use those functions without a need for context 🤔 |
Why not |
Good question. Yes, the route can be described as well by QueryParams which are separate from RouteParams. There might be also a need for other route's descriptors, like history state. ideally I would love to see it as a self contained object that has all the information to identify a route. Similarly like you send an API request to a search endpoint, or do DB query. That way you will be able to specify wide or exact, route you need. Putting the path into this object would be also nice, as that would ease the named routes integration as well. |
That's a good point. |
It's probably to do with how it matches routes by ids which are essentially the router registered path. I've had these APIs before routers Ive created before. However, I really like how minimal |
Describe the bug
Not a bug, it's a feature request.
I think that it would be nice to add a
params
prop to theA
component, for example:I'm proposing this for 2 reasons:
This is the API I'm thinking about:
When working with named routes there must be some way of providing params.
An alternative API could be
Your Example Website or App
Steps to Reproduce the Bug or Issue
Expected behavior
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: