-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
update nested router docs #2535
Conversation
Visit the preview URL for this PR (updated for commit af4c39a): https://yew-rs--pr2535-doccu-router-s42wrptb.web.app (expires Sun, 27 Mar 2022 10:09:33 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
@@ -425,8 +433,6 @@ enum MainRoute { | |||
News, | |||
#[at("/contact")] | |||
Contact, | |||
#[at("/settings/:s")] | |||
Settings, |
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.
I think modifying the settings variant to the following would fix it?
#[at("/settings/*s")]
Settings {
s: String,
}
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.
What do you mean?
There was no bug in the actual code before, but users kept trying to add /settings
and that does not get matched, its a bug.
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.
I thought route_recognizer
can match wildcard optionally...
In this case you can fix it with:
#[at("/settings/")]
SettingsHome,
#[at("/settings/*s")]
Settings,
and match it with:
MainRoute::SettingsHome | MainRoute::Settings => {}
This is still a less than ideal fix, but better than matching it in NotFound.
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.
Im like 80% sure SettingsHome wont match, let me try...
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.
Wait you wanted SettingsHome
to be in MainRoute
that is bad as we want all nested routes to be in the SettingsRoute
enum.
Kind of defeats the purpose if to go home of settings i cant use SettingsRoute
and am forced into using parent route.
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 match /settings/
again in the SettingsRoute
?
MainRoute::SettingsHome | MainRoute::Settings => {
html! { <Switch<SettingsRoute> render={Switch::render(switch_settings)} /> }
}
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.
ok that does work, let me update then...
Description
Router nested example is bugged in a way where you cant have
settings/
page. My edits fix this.Checklist
cargo make pr-flow