diff --git a/examples/readme.rs b/examples/readme.rs index 405953712..38eed4469 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -1,7 +1,3 @@ -//! Example: README.md showcase -//! -//! The example from the README.md. - use dioxus::prelude::*; fn main() { @@ -12,8 +8,20 @@ fn app() -> Element { let mut count = use_signal(|| 0); rsx! { - h1 { "High-Five counter: {count}" } + Child { count: "High-Five counter: {count}" } + Child { count: "count" } button { onclick: move |_| count += 1, "Up high!" } button { onclick: move |_| count -= 1, "Down low!" } } } + +#[derive(Props, Clone, PartialEq)] +struct ChildProps { + count: Option, +} + +fn Child(props: ChildProps) -> Element { + rsx! { + h1 { "{props.count.unwrap_or_default()}" } + } +} diff --git a/packages/core-macro/src/props/mod.rs b/packages/core-macro/src/props/mod.rs index b6d9173f1..15c55d470 100644 --- a/packages/core-macro/src/props/mod.rs +++ b/packages/core-macro/src/props/mod.rs @@ -3,8 +3,8 @@ //! However, it has been adopted to fit the Dioxus Props builder pattern. //! //! For Dioxus, we make a few changes: -//! - [ ] Automatically implement Into