fix: messed up how lifetimes worked, need to render once per component

This commit is contained in:
Jonathan Kelley committed 2021-10-29 21:43:21 -04:00
1 parent 0e9d5fc530
commit ba9e1dbb8f
33 files changed
+323 -184

No files matched your search

+4 -4
View File
@@ -20,7 +20,7 @@ fn main() {
dioxus::desktop::launch(App, |c| c);
}
fn App((cx, props): Component<()>) -> Element {
fn App((cx, props): Scope<()>) -> Element {
let text: &mut Vec<String> = cx.use_hook(|_| vec![String::from("abc=def")], |f| f, |_| {});
let first = text.get_mut(0).unwrap();
@@ -43,7 +43,7 @@ impl<'a> Drop for C1Props<'a> {
fn drop(&mut self) {}
}
fn Child1<'a>((cx, props): Component<'a, C1Props>) -> Element<'a> {
fn Child1<'a>((cx, props): Scope<'a, C1Props>) -> Element<'a> {
let (left, right) = props.text.split_once("=").unwrap();
cx.render(rsx! {
@@ -59,7 +59,7 @@ struct C2Props<'a> {
text: &'a str,
}
fn Child2<'a>((cx, props): Component<'a, C2Props>) -> Element<'a> {
fn Child2<'a>((cx, props): Scope<'a, C2Props>) -> Element<'a> {
cx.render(rsx! {
Child3 {
text: props.text
@@ -72,7 +72,7 @@ struct C3Props<'a> {
text: &'a str,
}
fn Child3<'a>((cx, props): Component<'a, C3Props>) -> Element<'a> {
fn Child3<'a>((cx, props): Scope<'a, C3Props>) -> Element<'a> {
cx.render(rsx! {
div { "{props.text}"}
})