diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 2c877d7..7dfb5da 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -24,7 +24,6 @@ fn main() { fn app(cx: &Arc) -> View { let count = use_state(0); - let mount = use_mount(); cx.on_event({ let count = count.clone(); @@ -41,14 +40,22 @@ fn app(cx: &Arc) -> View { }); rsx! { - if %count, mount as _, (*count.get() > 0) { + // Static scope + my_component (ctx, view) { + let area = ctx.allocate(5, 0, 10, 10); + ctx.draw_view(area, view); + } + + // Dynamic scope + if %count (*count.get() > 5) { my_component (ctx, view) { - let area = ctx.allocate(10, 0, 10, 10); + let area = ctx.allocate(18, 0, 10, 10); ctx.draw_view(area, view); } } - for %count, mount as _, (i in 0..count.get_dl()) { + // Dynamic scope + for %count (i in 0..count.get_dl()) { "{i}" } } diff --git a/src/component.rs b/src/component.rs index 0d43ed2..af20a4b 100644 --- a/src/component.rs +++ b/src/component.rs @@ -150,6 +150,8 @@ impl Context { }); self.scopes.lock().unwrap().push(scope.clone()); + drawer(&scope); + use_effect( { let scope = scope.clone();