2021-07-06 12:13:00 -04:00
|
|
|
//! Example: README.md showcase
|
|
|
|
//!
|
2021-07-11 19:31:07 -04:00
|
|
|
//! The example from the README.md.
|
2021-07-06 12:13:00 -04:00
|
|
|
|
2021-07-07 13:51:55 -04:00
|
|
|
use dioxus::prelude::*;
|
2021-12-29 21:28:28 -05:00
|
|
|
|
2021-07-06 12:13:00 -04:00
|
|
|
fn main() {
|
2022-01-02 18:35:38 -05:00
|
|
|
dioxus::desktop::launch(app);
|
2021-07-06 12:13:00 -04:00
|
|
|
}
|
|
|
|
|
2022-01-02 18:35:38 -05:00
|
|
|
fn app(cx: Scope) -> Element {
|
2022-01-25 21:41:40 -05:00
|
|
|
let (count, set_count) = use_state(&cx, || 0);
|
2021-07-06 12:13:00 -04:00
|
|
|
|
|
|
|
cx.render(rsx! {
|
2021-07-08 23:25:27 -04:00
|
|
|
div {
|
2021-07-11 19:31:07 -04:00
|
|
|
h1 { "High-Five counter: {count}" }
|
2022-01-25 21:41:40 -05:00
|
|
|
button { onclick: move |_| set_count(count + 1), "Up high!" }
|
|
|
|
button { onclick: move |_| set_count(count - 1), "Down low!" }
|
2021-07-08 23:25:27 -04:00
|
|
|
}
|
2021-07-06 12:13:00 -04:00
|
|
|
})
|
2022-01-02 18:35:38 -05:00
|
|
|
}
|