docs: update readme with new usestate
This commit is contained in:
1 parent
fb1a848124
commit
977ae1d44e
2 files changed
+7
-7
No files matched your search
@@ -62,13 +62,13 @@ Dioxus is a portable, performant, and ergonomic framework for building cross-pla
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
let (count, set_count) = use_state(&cx, || 0);
|
let count = use_state(&cx, || 0);
|
||||||
|
|
||||||
cx.render(rsx!(
|
cx.render(rsx! {
|
||||||
h1 { "High-Five counter: {count}" }
|
h1 { "High-Five counter: {count}" }
|
||||||
button { onclick: move |_| set_count(count + 1), "Up high!" }
|
button { onclick: move |_| count.set(count + 1), "Up high!" }
|
||||||
button { onclick: move |_| set_count(count - 1), "Down low!" }
|
button { onclick: move |_| count.set(count - 1), "Down low!" }
|
||||||
))
|
})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,8 @@ fn app(cx: Scope) -> Element {
|
|||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
div {
|
div {
|
||||||
h1 { "High-Five counter: {count}" }
|
h1 { "High-Five counter: {count}" }
|
||||||
button { onclick: move |_| *count.make_mut() += 1, "Up high!" }
|
button { onclick: move |_| count.set(count + 1), "Up high!" }
|
||||||
button { onclick: move |_| *count.make_mut() -= 1, "Down low!" }
|
button { onclick: move |_| count.set(count - 1), "Down low!" }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user