feat: re-unify set_state
This commit is contained in:
1 parent
3928856a9b
commit
6c3f5195f4
16 files changed
+199
-136
No files matched your search
+3
-3
@@ -7,7 +7,7 @@ fn main() {
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let (val, set_val) = use_state(&cx, || 5);
|
||||
let val = use_state(&cx, || 5);
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
@@ -21,12 +21,12 @@ fn app(cx: Scope) -> Element {
|
||||
height: "80%",
|
||||
width: "80%",
|
||||
Die {
|
||||
value: *val,
|
||||
value: **val,
|
||||
keep: true,
|
||||
onclick: move |_| {
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
set_val(rng.gen_range(1..6));
|
||||
val.set(rng.gen_range(1..6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user