dioxus/examples/readme.rs

19 lines
410 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() {
dioxus::web::launch(Example)
}
fn Example(cx: Context<()>) -> VNode {
2021-07-07 20:19:10 +00:00
let name = use_state(cx, || "..?");
2021-07-06 16:13:00 +00:00
cx.render(rsx! {
h1 { "Hello, {name}" }
button { "?", onclick: move |_| name.set("world!")}
2021-07-06 16:13:00 +00:00
button { "?", onclick: move |_| name.set("Dioxus 🎉")}
})
}