implement layouts and outlets

This commit is contained in:
Evan Almloff committed 2023-05-20 16:32:48 -05:00
1 parent f4227c7311
commit fbd333e334
10 files changed
+910 -259

No files matched your search

+12 -2
View File
@@ -59,12 +59,22 @@ fn Route6(cx: Scope, extra: Vec<String>) -> Element {
}
}
#[inline_props]
fn Nested(cx: Scope, nested: String) -> Element {
render! {
div{
"Nested: {nested:?}"
}
}
}
#[rustfmt::skip]
#[derive(Routable, Clone, Debug, PartialEq)]
#[routable]
#[derive(Clone, Debug, PartialEq)]
enum Route {
#[route("/(dynamic)" Route1)]
Route1 { dynamic: String },
#[nest("/hello_world")]
#[nest("/(nested)" nested { nested: String } Nested)]
#[route("/" Route2)]
Route2 {},
// #[redirect("/(dynamic)/hello_world")]
+35
View File
@@ -0,0 +1,35 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_router_core::*;
use dioxus_router_macro::*;
#[inline_props]
fn Route1(cx: Scope, dynamic: String) -> Element {
render! {
div{
"Route1: {dynamic}"
}
}
}
#[inline_props]
fn Nested(cx: Scope, nested: String) -> Element {
render! {
div{
"Nested: {nested:?}"
}
}
}
#[rustfmt::skip]
#[routable]
#[derive(Clone, Debug, PartialEq)]
enum Route {
#[nest("/(nested)" nested { nested: String } Nested)]
#[route("/(dynamic)" Route1)]
Route1 { dynamic: String },
#[end_nest]
#[route("/(dynamic)" Route1)]
Route2 { dynamic: String },
}