readme.rs 591 B

12345678910111213141516171819202122232425
  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. use_effect(cx, (), move |()| async {});
  11. use_effect(cx, (count.get(),), move |(count,)| async move {
  12. move || println!("Count unmounted from {}", count)
  13. });
  14. cx.render(rsx! {
  15. h1 { "High-Five counter: {count}" }
  16. button { onclick: move |_| count += 1, "Up high!" }
  17. button { onclick: move |_| count -= 1, "Down low!" }
  18. })
  19. }