pub fn Outlet<R: Routable + Clone>() -> Element
Expand description
An outlet for the current content.
The Outlet
is aware of how many Outlet
s it is nested within. It will render the content
of the active route that is exactly as deep.
ยงExample
#[derive(Clone, Routable)]
#[rustfmt::skip]
enum Route {
#[nest("/wrap")]
#[layout(Wrapper)] // Every layout component must have one Outlet
#[route("/")]
Child {},
#[end_layout]
#[end_nest]
#[route("/")]
Index {},
}
#[component]
fn Index() -> Element {
rsx!(
label {
"Index"
}
)
}
#[component]
fn Wrapper() -> Element {
rsx!(
label { "App" }
Outlet::<Route> {} // The content of child routes will be rendered here
)
}
#[component]
fn Child() -> Element {
rsx!(
label {
"Child"
}
)
}