-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[added] url parameter rules #2442
Conversation
I added the nesting as well. I don't know how much is useful though, as @taion said, you want to put the rule on the same component the parameter is declared, for readability, but it wasn't hard to implement so I put it. Let me know what you think, I am working on updating the doc in the meantime. |
Haven't had a chance to look at this yet, but should we close #2402? |
@taion If we all agree on this syntax, I would say so :) |
I think in a vacuum I'd have preferred the Flask-style syntax for specifying URL variables (wrapped in angle brackets rather than prefixed with a colon - but probably still with the external type specification), but given what we already have, this is better. |
const type = element.type | ||
const route = createRoute(type.defaultProps, element.props) | ||
|
||
if(parentRoute && parentRoute.params && route.params) { | ||
route.params = mergeObjects(parentRoute.params, route.params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use ES6 object spread stuff to write this as
route.params = {...parentRoute.params, ...route.params}
I haven't had time to look at this in depth, but I really think the right way to do this architecturally per @mjackson's comment is to split out something with an API that looks like |
You mean like a separate repo right? So we aim at refactoring out |
You mean |
whops, |
I'm closing this PR for now since the development is in a separate repo. |
Closes #2286
Another pull request for custom matching parameter rules, this time with the specifics proposed by @th0r
This time was easier, and I like the final result more. I still need to add the documentation and the rule inheritance feature, but let men know what you think for now