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

[added] url parameter rules #2442

Closed
wants to merge 8 commits into from
Closed

Conversation

itajaja
Copy link

@itajaja itajaja commented Nov 1, 2015

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

@itajaja
Copy link
Author

itajaja commented Nov 1, 2015

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.

@taion taion added this to the v1.1 milestone Nov 2, 2015
@taion
Copy link
Contributor

taion commented Nov 2, 2015

Haven't had a chance to look at this yet, but should we close #2402?

@itajaja
Copy link
Author

itajaja commented Nov 2, 2015

@taion If we all agree on this syntax, I would say so :)

@taion
Copy link
Contributor

taion commented Nov 2, 2015

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)
Copy link
Contributor

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}

@taion
Copy link
Contributor

taion commented Nov 2, 2015

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 matchPattern into a separate library.

@itajaja
Copy link
Author

itajaja commented Nov 2, 2015

You mean like a separate repo right? So we aim at refactoring out RouteUtils, with caching and all? Before embarking in that, I want to make sure we are in-line. suggestions (naming, scope, etc.) are welcome

@taion
Copy link
Contributor

taion commented Nov 3, 2015

You mean PatternUtils, right? That's my thought - pattern-matching is not React Router specific.

@itajaja
Copy link
Author

itajaja commented Nov 3, 2015

whops, patternUtils. Let's see what I am able to do.

@taion
Copy link
Contributor

taion commented Nov 5, 2015

I'm closing this PR for now since the development is in a separate repo.

@taion taion closed this Nov 5, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 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

Successfully merging this pull request may close these issues.

2 participants