mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-23 19:13:08 +00:00
41 lines
757 B
Rust
41 lines
757 B
Rust
#![allow(non_snake_case, unused)]
|
|
use dioxus::prelude::*;
|
|
use dioxus_router::prelude::*;
|
|
|
|
// ANCHOR: router
|
|
#[derive(Routable, Clone, PartialEq)]
|
|
enum Route {
|
|
#[route("/")]
|
|
Index {},
|
|
#[route("/home")]
|
|
Home {},
|
|
}
|
|
|
|
#[inline_props]
|
|
fn Home(cx: Scope) -> Element {
|
|
render! {
|
|
p { "Home" }
|
|
}
|
|
}
|
|
|
|
#[inline_props]
|
|
fn Index(cx: Scope) -> Element {
|
|
render! {
|
|
p { "Index" }
|
|
}
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
render! {
|
|
Router {
|
|
config: || RouterConfig::default().on_update(|state|{
|
|
(state.current() == Route::Index {}).then_some(
|
|
NavigationTarget::Internal(Route::Home {})
|
|
)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
// ANCHOR_END: router
|
|
|
|
fn main() {}
|