update: modify usestate to be borrowed

This commit is contained in:
Jonathan Kelley committed 2022-01-16 15:56:48 -05:00
1 parent 8e842231e4
commit 58839f47ba
10 files changed
+237 -419

No files matched your search

+3 -3
View File
@@ -9,13 +9,13 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let mut count = use_state(&cx, || 0);
let count = use_state(&cx, || 0);
cx.render(rsx! {
div {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
button { onclick: move |_| *count.modify() += 1, "Up high!" }
button { onclick: move |_| *count.modify() -= 1, "Down low!" }
}
})
}