mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-24 05:03:06 +00:00
e04a6d63a5
This commit moves the tests out of core so rust analyzer is happier with the workspace.
46 lines
844 B
Rust
46 lines
844 B
Rust
#![allow(non_snake_case)]
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
#[test]
|
|
fn test_borrowed_state() {
|
|
let _ = VirtualDom::new(Parent);
|
|
}
|
|
|
|
fn Parent(cx: Scope) -> Element {
|
|
let value = cx.use_hook(|_| String::new());
|
|
|
|
cx.render(rsx! {
|
|
div {
|
|
Child { name: value }
|
|
Child { name: value }
|
|
Child { name: value }
|
|
Child { name: value }
|
|
}
|
|
})
|
|
}
|
|
|
|
#[derive(Props)]
|
|
struct ChildProps<'a> {
|
|
name: &'a str,
|
|
}
|
|
|
|
fn Child<'a>(cx: Scope<'a, ChildProps<'a>>) -> Element {
|
|
cx.render(rsx! {
|
|
div {
|
|
h1 { "it's nested" }
|
|
Child2 { name: cx.props.name }
|
|
}
|
|
})
|
|
}
|
|
|
|
#[derive(Props)]
|
|
struct Grandchild<'a> {
|
|
name: &'a str,
|
|
}
|
|
|
|
fn Child2<'a>(cx: Scope<'a, Grandchild<'a>>) -> Element {
|
|
cx.render(rsx! {
|
|
div { "Hello {cx.props.name}!" }
|
|
})
|
|
}
|