add a desktop eval example

This commit is contained in:
Ilya Maximov committed 2022-03-19 03:11:30 +01:00
1 parent 40869b36ad
commit 5e475fadd9
1 file changed
+25
+25
View File
@@ -0,0 +1,25 @@
use dioxus::prelude::*;
fn main() {
dioxus::desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let script = use_state(&cx, String::new);
let eval = use_eval(&cx);
cx.render(rsx! {
div {
input {
placeholder: "Enter an expression",
value: "{script}",
oninput: move |e| script.set(e.value.clone()),
}
button {
onclick: move |_| eval(script),
"Execute"
}
}
})
}