2021-09-21 17:13:15 +00:00
|
|
|
use dioxus::{nodes::VSuspended, prelude::*, DomEdit, TestDom};
|
|
|
|
use dioxus_core as dioxus;
|
2021-09-25 01:46:23 +00:00
|
|
|
use dioxus_core_macro::*;
|
2021-09-21 17:13:15 +00:00
|
|
|
use dioxus_html as dioxus_elements;
|
|
|
|
|
2021-10-16 21:37:28 +00:00
|
|
|
static Parent: FC<()> = |(cx, props)| {
|
2021-09-21 17:13:15 +00:00
|
|
|
let value = cx.use_hook(|_| String::new(), |f| &*f, |_| {});
|
|
|
|
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
Child { name: value }
|
|
|
|
Child { name: value }
|
|
|
|
Child { name: value }
|
|
|
|
Child { name: value }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
#[derive(Props)]
|
|
|
|
struct ChildProps<'a> {
|
|
|
|
name: &'a String,
|
|
|
|
}
|
|
|
|
|
2021-10-16 21:37:28 +00:00
|
|
|
fn Child<'a>((cx, props): Component<'a, ChildProps>) -> DomTree<'a> {
|
2021-09-21 17:13:15 +00:00
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
h1 { "it's nested" }
|
|
|
|
Child2 { name: props.name }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Props)]
|
|
|
|
struct Grandchild<'a> {
|
|
|
|
name: &'a String,
|
|
|
|
}
|
|
|
|
|
2021-10-16 21:37:28 +00:00
|
|
|
fn Child2<'a>((cx, props): Component<'a, Grandchild>) -> DomTree<'a> {
|
2021-09-21 17:13:15 +00:00
|
|
|
cx.render(rsx! {
|
|
|
|
div { "Hello {props.name}!" }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_borrowed_state() {}
|