feat: re-unify set_state

This commit is contained in:
Jonathan Kelley committed 2022-03-04 14:29:45 -05:00
1 parent 3928856a9b
commit 6c3f5195f4
16 files changed
+199 -136

No files matched your search

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