webview_web.rs 975 B

1234567891011121314151617181920212223242526272829
  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: Component<()> = |cx, props| {
  17. let mut count = use_state(cx, || 0);
  18. cx.render(rsx! {
  19. div {
  20. h1 { "Hifive counter: {count}" }
  21. button { onclick: move |_| count += 1, "Up high!" }
  22. button { onclick: move |_| count -= 1, "Down low!" }
  23. }
  24. })
  25. };