dioxus/examples/readme.rs

21 lines
439 B
Rust
Raw Normal View History

2021-07-06 16:13:00 +00:00
//! Example: README.md showcase
//!
//! The example from the README.md
use dioxus::prelude::*;
2021-07-06 16:13:00 +00:00
fn main() {
2021-07-09 03:25:27 +00:00
dioxus::web::launch(App)
2021-07-06 16:13:00 +00:00
}
2021-07-09 03:25:27 +00:00
static App: FC<()> = |cx| {
let mut count = use_state(cx, || 0);
2021-07-06 16:13:00 +00:00
cx.render(rsx! {
2021-07-09 03:25:27 +00:00
div {
h1 { "Hifive counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
}
2021-07-06 16:13:00 +00:00
})
2021-07-09 03:25:27 +00:00
};