Browse Source

feat: works with components

Jonathan Kelley 2 năm trước cách đây
mục cha
commit
dddbcfd5e2
2 tập tin đã thay đổi với 16 bổ sung23 xóa
  1. 1 1
      packages/core/src/factory.rs
  2. 15 22
      packages/ssr/src/template.rs

+ 1 - 1
packages/core/src/factory.rs

@@ -95,7 +95,7 @@ impl ScopeState {
         // }
 
         DynamicNode {
-            path: &[],
+            path: &[0],
             kind: DynamicNodeKind::Component {
                 name: fn_name,
                 can_memoize: P::IS_STATIC,

+ 15 - 22
packages/ssr/src/template.rs

@@ -189,41 +189,34 @@ fn children_processes_properly() {
     use dioxus::prelude::*;
 
     fn app(cx: Scope) -> Element {
+        let d = 123;
+
         render! {
             div {
-                "yo!"
-                "yo!"
-                "yo!"
-                "yo!"
-                "yo!"
-                Child {}
-                Child {}
-                Child {}
-                Child {}
                 ChildWithChildren {
-                    "hii"
+                    p {
+                        "{d}"
+                        "hii"
+                    }
                 }
-                (0..10).map(|f| rsx! {
-                    "div {f}"
-                })
             }
         }
     }
 
-    /// Yo its the child component!
-    fn Child(cx: Scope) -> Element {
-        render! ( div { "child" } )
-    }
-
     #[inline_props]
     fn ChildWithChildren<'a>(cx: Scope<'a>, children: Element<'a>) -> Element {
         render! {
-            div {
-                "div"
-                children
-            }
+             h1 { children }
         }
     }
 
     let mut dom = VirtualDom::new(app);
+
+    let mut mutations = vec![];
+    dom.rebuild(&mut mutations);
+    dbg!(mutations);
+
+    let mut mutations = vec![];
+    dom.rebuild(&mut mutations);
+    dbg!(mutations);
 }