mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-24 05:03:06 +00:00
36 lines
571 B
Rust
36 lines
571 B
Rust
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(app);
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
let count = if cx.generation() % 2 == 0 { 10 } else { 0 };
|
|
|
|
println!("Generation: {}", cx.generation());
|
|
|
|
if cx.generation() < 10 {
|
|
cx.needs_update();
|
|
}
|
|
|
|
render! {
|
|
for _ in 0..count {
|
|
drop_child {}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn drop_child(cx: Scope) -> Element {
|
|
cx.use_hook(|| Drops);
|
|
render! {
|
|
div{}
|
|
}
|
|
}
|
|
|
|
struct Drops;
|
|
|
|
impl Drop for Drops {
|
|
fn drop(&mut self) {
|
|
println!("Dropped!");
|
|
}
|
|
}
|