feat: enable addassign for usestate

This commit is contained in:
Jonathan Kelley committed 2022-03-05 17:07:34 -05:00
1 parent e4fac574ed
commit a4ab2d9de0
3 files changed
+32 -11

No files matched your search

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