dioxus/examples/webview.rs

29 lines
914 B
Rust
Raw Normal View History

2021-01-22 20:50:16 +00:00
//! Example: Webview Renderer
2021-01-26 19:02:35 +00:00
//! -------------------------
2021-01-22 20:50:16 +00:00
//!
//! This example shows how to use the dioxus_webview crate to build a basic desktop application.
//!
//! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
//! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
//! into the native VDom instance.
2021-06-24 15:09:38 +00:00
//!
//! Currently, NodeRefs won't work properly, but all other event functionality will.
2021-01-22 20:50:16 +00:00
2021-01-21 16:10:31 +00:00
use dioxus::prelude::*;
2021-06-17 22:00:32 +00:00
fn main() {
2021-07-08 13:29:12 +00:00
dioxus::desktop::launch(App, |c| c);
2021-06-24 15:09:38 +00:00
}
2021-01-22 20:50:16 +00:00
2021-06-24 15:09:38 +00:00
static App: FC<()> = |cx| {
2021-07-08 14:17:51 +00:00
let mut count = use_state(cx, || 0);
2021-06-24 15:09:38 +00:00
cx.render(rsx! {
div {
2021-07-08 16:01:31 +00:00
h1 { "Hifive counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
2021-06-24 15:09:38 +00:00
}
})
};