fix: exampels

This commit is contained in:
Jonathan Kelley committed 2022-01-25 21:41:40 -05:00
1 parent 5c4bd0881b
commit a8952a9ee8
14 files changed
+400 -285

No files matched your search

+4 -4
View File
@@ -10,14 +10,14 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let count = use_state(&cx, || 0);
let (count, set_count) = use_state(&cx, || 0);
use_future(&cx, move || {
let mut count = count.for_async();
let set_count = set_count.to_owned();
async move {
loop {
tokio::time::sleep(Duration::from_millis(1000)).await;
count += 1;
set_count.modify(|f| f + 1);
}
}
});
@@ -26,7 +26,7 @@ fn app(cx: Scope) -> Element {
div {
h1 { "Current count: {count}" }
button {
onclick: move |_| count.set(0),
onclick: move |_| set_count(0),
"Reset the count"
}
}