Initial dynamic render
This commit is contained in:
+11
-4
@@ -24,7 +24,6 @@ fn main() {
|
|||||||
|
|
||||||
fn app(cx: &Arc<Context>) -> View {
|
fn app(cx: &Arc<Context>) -> View {
|
||||||
let count = use_state(0);
|
let count = use_state(0);
|
||||||
let mount = use_mount();
|
|
||||||
|
|
||||||
cx.on_event({
|
cx.on_event({
|
||||||
let count = count.clone();
|
let count = count.clone();
|
||||||
@@ -41,14 +40,22 @@ fn app(cx: &Arc<Context>) -> View {
|
|||||||
});
|
});
|
||||||
|
|
||||||
rsx! {
|
rsx! {
|
||||||
if %count, mount as _, (*count.get() > 0) {
|
// Static scope
|
||||||
my_component (ctx, view) {
|
my_component (ctx, view) {
|
||||||
let area = ctx.allocate(10, 0, 10, 10);
|
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(18, 0, 10, 10);
|
||||||
ctx.draw_view(area, view);
|
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}"
|
"{i}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ impl Context {
|
|||||||
});
|
});
|
||||||
self.scopes.lock().unwrap().push(scope.clone());
|
self.scopes.lock().unwrap().push(scope.clone());
|
||||||
|
|
||||||
|
drawer(&scope);
|
||||||
|
|
||||||
use_effect(
|
use_effect(
|
||||||
{
|
{
|
||||||
let scope = scope.clone();
|
let scope = scope.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user