mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-24 05:03:06 +00:00
26 lines
530 B
Rust
26 lines
530 B
Rust
|
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"
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|