DioxusLabs / DioxusLabs/dioxus
Router dynamic segments
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
In the below code, even though page is navigated from page 1 to page2, it is still showing page 1 content, why is it so? Thanks
```rust
use dioxus::prelude::*;
#[derive(Clone, Routable, Debug, PartialEq)]
pub enum Route {
#[layout(MyLinks)]
#[route("/")]
Home {},
#[route("/pages/:page_name")]
MyPage { page_name: String },
#[end_layout]
#[route("/:..route")]
PageNotFound { route: Vec },
}
fn main() {
dioxus::launch(app);
}
fn app() -> Element {
rsx! {
Router:: {}
}
}
#[component]
pub fn MyLinks() -> Element {
rsx! {
Link {to: Route::Home{}, "Home"}
Link {to: Route::MyPage {page_name: "Page1".to_string()}, " Page1 "}
Link {to: Route::MyPage {page_name: "Page2".to_string()}, " Page2 "}
Outlet::{}
}
}
#[component]
pub fn Home() -> Element {
rsx! {
h1 { "Welcome" }
}
}
#[component]
pub fn MyPage(page_name: String) -> Element {
let mut field_name = use_signal(|| page_name);
rsx! {
h1{"{field_name}"}
button{
onclick: move |_| {
field_name.set(format!("{}-k", field_name()));
},
"Click Me"
}
}
}
#[component]
fn PageNotFound(route: Vec) -> Element {
rsx! {
div{"{route:?}"}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the supplied Rust example and inspect the Router, MyLinks, and MyPage components, especially how the dynamic page_name route reaches MyPage. Confirm what happens when navigating from Page1 to Page2 and determine whether the displayed content should update while preserving or resetting field state; done means the expected navigation behavior is documented or reproduced with a clear fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100