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
@@ -15,16 +15,16 @@ fn main() {
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let (state, set_state) = use_state(&cx, PlayerState::new);
|
||||
let state = use_state(&cx, PlayerState::new);
|
||||
|
||||
cx.render(rsx!(
|
||||
div {
|
||||
h1 {"Select an option"}
|
||||
h3 { "The radio is... " [state.is_playing()] "!" }
|
||||
button { onclick: move |_| set_state.make_mut().reduce(PlayerAction::Pause),
|
||||
button { onclick: move |_| state.make_mut().reduce(PlayerAction::Pause),
|
||||
"Pause"
|
||||
}
|
||||
button { onclick: move |_| set_state.make_mut().reduce(PlayerAction::Play),
|
||||
button { onclick: move |_| state.make_mut().reduce(PlayerAction::Play),
|
||||
"Play"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user