dioxus/examples/webview.rs

32 lines
935 B
Rust
Raw Normal View History

2021-01-22 15:50:16 -05:00
//! Example: Webview Renderer
2021-01-26 14:02:35 -05:00
//! -------------------------
2021-01-22 15:50:16 -05: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 11:09:38 -04:00
//!
//! Currently, NodeRefs won't work properly, but all other event functionality will.
2021-01-22 15:50:16 -05:00
2021-01-21 11:10:31 -05:00
use dioxus::prelude::*;
2021-06-17 18:00:32 -04:00
fn main() {
2021-07-08 09:29:12 -04:00
dioxus::desktop::launch(App, |c| c);
2021-06-24 11:09:38 -04:00
}
2021-01-22 15:50:16 -05:00
2021-06-24 11:09:38 -04:00
static App: FC<()> = |cx| {
2021-07-08 10:17:51 -04:00
let mut count = use_state(cx, || 0);
2021-06-24 11:09:38 -04:00
cx.render(rsx! {
div {
h1 { "Dioxus Desktop Demo" }
p { "Count is {count}" }
button {
"Click to increment"
2021-07-08 10:17:51 -04:00
onclick: move |_| count += 1
2021-03-04 18:12:24 -05:00
}
2021-06-24 11:09:38 -04:00
}
})
};