mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-26 04:17:41 +00:00
24 lines
497 B
Rust
24 lines
497 B
Rust
|
#![allow(non_snake_case)]
|
||
|
use dioxus::prelude::*;
|
||
|
|
||
|
fn main() {
|
||
|
dioxus::desktop::launch(App);
|
||
|
}
|
||
|
|
||
|
// ANCHOR: component
|
||
|
fn App(cx: Scope) -> Element {
|
||
|
let list = use_ref(&cx, || Vec::new());
|
||
|
let list_formatted = format!("{:?}", *list.read());
|
||
|
|
||
|
cx.render(rsx!(
|
||
|
p { "Current list: {list_formatted}" }
|
||
|
button {
|
||
|
onclick: move |event| {
|
||
|
list.write().push(event)
|
||
|
},
|
||
|
"Click me!"
|
||
|
}
|
||
|
))
|
||
|
}
|
||
|
// ANCHOR_END: component
|