mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-24 05:03:06 +00:00
d9546d9504
* feat: use synchronous router design * feat: function to get router out of dom * chore: restructure workspace to use renderers as packages, not features
24 lines
664 B
Rust
24 lines
664 B
Rust
#![allow(non_snake_case)]
|
|
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(App);
|
|
}
|
|
|
|
// ANCHOR: component
|
|
fn App(cx: Scope) -> Element {
|
|
// ANCHOR: use_state_calls
|
|
let mut count_a = use_state(&cx, || 0);
|
|
let mut count_b = use_state(&cx, || 0);
|
|
// ANCHOR_END: use_state_calls
|
|
|
|
cx.render(rsx!(
|
|
h1 { "Counter_a: {count_a}" }
|
|
button { onclick: move |_| count_a += 1, "a++" }
|
|
button { onclick: move |_| count_a -= 1, "a--" }
|
|
h1 { "Counter_b: {count_b}" }
|
|
button { onclick: move |_| count_b += 1, "b++" }
|
|
button { onclick: move |_| count_b -= 1, "b--" }
|
|
))
|
|
}
|
|
// ANCHOR_END: component
|