mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-22 10:33:07 +00:00
40 lines
748 B
Rust
40 lines
748 B
Rust
#![allow(non_snake_case)]
|
|
|
|
use dioxus::prelude::*;
|
|
use dioxus_core as dioxus;
|
|
use dioxus_core_macro::*;
|
|
use dioxus_html as dioxus_elements;
|
|
|
|
fn main() {
|
|
let mut dom = VirtualDom::new(parent);
|
|
let edits = dom.rebuild();
|
|
dbg!(edits);
|
|
}
|
|
|
|
fn parent(cx: Scope) -> Element {
|
|
let value = cx.use_hook(|_| String::new());
|
|
|
|
cx.render(rsx! {
|
|
div {
|
|
child(
|
|
name: value,
|
|
h1 {"hi"}
|
|
)
|
|
}
|
|
})
|
|
}
|
|
|
|
#[derive(Props)]
|
|
struct ChildProps<'a> {
|
|
name: &'a str,
|
|
children: Element<'a>,
|
|
}
|
|
|
|
fn child<'a>(cx: Scope<'a, ChildProps<'a>>) -> Element {
|
|
cx.render(rsx! {
|
|
div {
|
|
"it's nested {cx.props.name}",
|
|
&cx.props.children
|
|
}
|
|
})
|
|
}
|