fix: scopes not dropping their hooks
This commit is contained in:
1 parent
1737c55575
commit
69a347a551
3 files changed
+48
-11
No files matched your search
@@ -0,0 +1,36 @@
|
||||
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! {
|
||||
(0..count).map(|_| rsx!{
|
||||
Comp {}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn Comp(cx: Scope) -> Element {
|
||||
cx.use_hook(|| Drops);
|
||||
render! {
|
||||
div{}
|
||||
}
|
||||
}
|
||||
|
||||
struct Drops;
|
||||
|
||||
impl Drop for Drops {
|
||||
fn drop(&mut self) {
|
||||
println!("Dropped!");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user