hifive.rs 767 B

12345678910111213141516171819202122232425262728
  1. //! An example where the dioxus vdom is running in a native thread, interacting with webview
  2. //! Content is passed from the native thread into the webview
  3. use dioxus_core as dioxus;
  4. use dioxus_core::prelude::*;
  5. fn main() {
  6. dioxus_desktop::launch(
  7. |builder| {
  8. builder
  9. .title("Test Dioxus App")
  10. .size(320, 480)
  11. .resizable(false)
  12. .debug(true)
  13. },
  14. (),
  15. App,
  16. )
  17. .expect("Webview finished");
  18. }
  19. static App: FC<()> = |cx, props| {
  20. let hifives = use_model(&cx, || 0);
  21. cx.render(rsx! {
  22. div {
  23. h1 { "Hi-fives collected: {hifives}" }
  24. button { "Hi five me!", onclick: move |_| *hifives.get_mut() += 1 }
  25. }
  26. })
  27. };