-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
(preact-iso) - support route parameters #300
Conversation
Size Change: +205 B (0%) Total Size: 693 kB
ℹ️ View Unchanged
|
Might be useful to add a route with parameters to the |
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.
Here's a few simplifications.
I've been able to try this branch, and the routing part works great! Can't wait to see this being merged. But... the |
@smeijer You mean like |
Exactly! Extending the example from the docs in this PR: const App = () => (
<LocationProvider>
<ErrorBoundary>
<Router>
<Home path="/" />
<Profiles path="/profiles" />
<Profile path="/profiles/:id" />
<Profile path="/profiles/:id/:tab" />
</Router>
</ErrorBoundary>
</LocationProvider>
); When on {
id: '123',
} When on {
id: '123',
tab: 'hobbies',
} That's matching behavior with |
@smeijer the trick with const App = () => (
<LocationProvider>
<ErrorBoundary>
<div id="app">
<header>
<Router>
<Profile path="/profiles/:profile" />
</Router>
</header>
<Router>
<Profile path="/profiles/:id" />
</Router>
</div>
</ErrorBoundary>
</LocationProvider>
); Another option that was floated was to allow passing a path pattern to const { id } = useLocation('/profiles/:id').params; It's more direct, but I wonder if it'd be workable? |
@developit, I understand. I've made a small sandbox to show that Your example As an alternative, I was thinking to simply merge all the paramters, and return the merge result instead. Your example from above would lead to Ideally, the params would be scoped to
Definitely workable. |
Merging all parameters seems like a pretty reasonable default. I'll have to noodle on how to implement it though... Another option I thought of would be to have |
The "other option" looks to me like the preferred way to go. (to have
Merging looked like the easy solution to me in case the above wouldn't be possible, but the side effects might not be worth it. Especially if the better option can be done. I mean, merging creates the situation where one might depend on the absence of params, while another unrelated route is setting them. When developers work with generic names like |
Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
6aaaa63
to
39a4098
Compare
Superseded by #354 |
Resolves: #298