webview_web.rs 998 B

123456789101112131415161718192021222324252627282930
  1. #![allow(non_upper_case_globals, non_snake_case)]
  2. //! Example: Webview Renderer
  3. //! -------------------------
  4. //!
  5. //! This example shows how to use the dioxus_desktop crate to build a basic desktop application.
  6. //!
  7. //! Under the hood, the dioxus_desktop crate bridges a native Dioxus VirtualDom with a custom prebuilt application running
  8. //! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
  9. //! into the native VDom instance.
  10. //!
  11. //! Currently, NodeRefs won't work properly, but all other event functionality will.
  12. use dioxus::prelude::*;
  13. fn main() {
  14. dioxus::web::launch(App, |c| c);
  15. }
  16. static App: FC<()> = |(cx, props)| {
  17. let mut count = use_state(cx, || 0);
  18. cx.render(rsx! {
  19. div {
  20. h1 { "Hifive counter: {count}" }
  21. {cx.children()}
  22. button { onclick: move |_| count += 1, "Up high!" }
  23. button { onclick: move |_| count -= 1, "Down low!" }
  24. }
  25. })
  26. };