readme.rs 490 B

123456789101112131415161718192021222324252627
  1. //! Example: README.md showcase
  2. //!
  3. //! The example from the README.md.
  4. use dioxus::prelude::*;
  5. fn main() {
  6. dioxus::desktop::launch(app);
  7. }
  8. fn app(cx: Scope) -> Element {
  9. let mut count = use_state(&cx, || 0);
  10. let a = rsx! {
  11. div {
  12. key: "a"
  13. }
  14. };
  15. cx.render(rsx! {
  16. h1 { "High-Five counter: {count}" }
  17. button { onclick: move |_| count += 1, "Up high!" }
  18. button { onclick: move |_| count -= 1, "Down low!" }
  19. })
  20. }