12345678910111213141516171819202122 |
- #![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);
- cx.render(rsx!(
- p { "Current list: {list.read():?}" }
- button {
- onclick: move |event| {
- list.with_mut(|list| list.push(event));
- },
- "Click me!"
- }
- ))
- }
- // ANCHOR_END: component
|