webview.rs 938 B

1234567891011121314151617181920212223242526272829
  1. //! Example: Webview Renderer
  2. //! -------------------------
  3. //!
  4. //! This example shows how to use the dioxus_desktop crate to build a basic desktop application.
  5. //!
  6. //! Under the hood, the dioxus_desktop crate bridges a native Dioxus VirtualDom with a custom prebuit application running
  7. //! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
  8. //! into the native VDom instance.
  9. //!
  10. //! Currently, NodeRefs won't work properly, but all other event functionality will.
  11. use dioxus::prelude::*;
  12. fn main() {
  13. env_logger::init();
  14. dioxus::desktop::launch(App, |c| c);
  15. }
  16. static App: FC<()> = |cx| {
  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. };