This change switches back to the original `ctx<props>` syntax for commponents. This lets lifetime elision to remove the need to match exactly which lifetime (props or ctx) gets carried to the output. As such, `Props` is currently required to be static. It *is* possible to loosen this restriction, and will be done in the future, though only through adding metadata about the props through the Props derive macro. Implementing the IS_STATIC trait is unsafe, so the derive macro will do it through some heuristics. For now, this unlocks sharing vnodes from parents to children, enabling pass-thru components, fragments, portals, etc.
46 lines
665 B
Rust
46 lines
665 B
Rust
//! DioxusLabs Webiste
|
|
//! ------------------
|
|
//!
|
|
//! This is the example powering the DioxusLabs website :)
|
|
//! It's always good to dogfood your code, right?
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
fn main() {}
|
|
|
|
mod state {
|
|
pub struct AppState {
|
|
cur_page: Route,
|
|
}
|
|
|
|
pub enum Route {
|
|
Homepage,
|
|
Docs,
|
|
}
|
|
}
|
|
|
|
static APP: FC<()> = |ctx| {
|
|
ctx.render(html! {
|
|
<div>
|
|
|
|
<div>
|
|
})
|
|
};
|
|
|
|
/// Draw the navbar on top of the screen
|
|
static Navbar: FC<state::Route> = |ctx| {
|
|
ctx.render(html! {
|
|
<div>
|
|
|
|
<div>
|
|
})
|
|
};
|
|
|
|
static Homepage: FC<()> = |ctx| {
|
|
ctx.render(html! {
|
|
<div>
|
|
|
|
<div>
|
|
})
|
|
};
|