浏览代码

chore: pull out for loop

Jonathan Kelley 2 年之前
父节点
当前提交
8f118fe3fd
共有 1 个文件被更改,包括 8 次插入9 次删除
  1. 8 9
      examples/simple_list.rs

+ 8 - 9
examples/simple_list.rs

@@ -6,7 +6,7 @@ fn main() {
 
 fn app(cx: Scope) -> Element {
     cx.render(rsx!(
-        div { id: "123123123",
+        div {
             // Use Map directly to lazily pull elements
             (0..10).map(|f| rsx! { "{f}" }),
 
@@ -20,15 +20,14 @@ fn app(cx: Scope) -> Element {
             // Use optionals
             Some(rsx! { "Some" }),
 
-            // use a for loop or unterminated conditional
-            div {
-                for name in 0..10 {
-                    rsx! { "{name}" }
-                }
+            // use a for loop
+            for name in 0..10 {
+                rsx! { "{name}" }
+            }
 
-                if true {
-                    rsx!{ "hello world!" }
-                }
+            // Or even use an unterminated conditional
+            if true {
+                rsx!{ "hello world!" }
             }
         }
     ))