Initial dynamic render

This commit is contained in:
2026-01-25 20:46:26 +01:00
parent eb702dce45
commit 98598bec15
2 changed files with 13 additions and 4 deletions
+11 -4
View File
@@ -24,7 +24,6 @@ fn main() {
fn app(cx: &Arc<Context>) -> 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<Context>) -> 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}"
}
}
+2
View File
@@ -150,6 +150,8 @@ impl Context {
});
self.scopes.lock().unwrap().push(scope.clone());
drawer(&scope);
use_effect(
{
let scope = scope.clone();