feat: mvoe away from compound context
This commit is contained in:
1 parent
bfdcb20437
commit
a2c7d17b05
103 files changed
+309
-293
No files matched your search
@@ -22,7 +22,7 @@ fn main() {
|
||||
dioxus::desktop::launch(App, |c| c);
|
||||
}
|
||||
|
||||
fn App<'a>(cx: Context<'a, ()>) -> DomTree<'a> {
|
||||
fn App<'a>(cx: Context<'a>, props: &()) -> DomTree<'a> {
|
||||
let text: &'a mut Vec<String> = cx.use_hook(|_| vec![String::from("abc=def")], |f| f, |_| {});
|
||||
|
||||
let first = text.get_mut(0).unwrap();
|
||||
@@ -45,8 +45,8 @@ impl<'a> Drop for C1Props<'a> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
fn Child1<'a>(cx: Context<'a, C1Props>) -> DomTree<'a> {
|
||||
let (left, right) = cx.text.split_once("=").unwrap();
|
||||
fn Child1<'a>(cx: Context<'a>, props: &'a C1Props) -> DomTree<'a> {
|
||||
let (left, right) = props.text.split_once("=").unwrap();
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
@@ -66,10 +66,10 @@ impl<'a> Drop for C2Props<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn Child2<'a>(cx: Context<'a, C2Props>) -> DomTree<'a> {
|
||||
fn Child2<'a>(cx: Context<'a>, props: &'a C2Props) -> DomTree<'a> {
|
||||
cx.render(rsx! {
|
||||
Child3 {
|
||||
text: cx.text
|
||||
text: props.text
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -79,8 +79,8 @@ struct C3Props<'a> {
|
||||
text: &'a str,
|
||||
}
|
||||
|
||||
fn Child3<'a>(cx: Context<'a, C3Props>) -> DomTree<'a> {
|
||||
fn Child3<'a>(cx: Context<'a>, props: &C3Props) -> DomTree<'a> {
|
||||
cx.render(rsx! {
|
||||
div { "{cx.text}"}
|
||||
div { "{props.text}"}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user