docs: more docs and an errorhandling example
This commit is contained in:
1 parent
9846e0947b
commit
3acd643afb
8 files changed
+378
-33
No files matched your search
@@ -0,0 +1,22 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::desktop::launch(app);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let val = use_state(&cx, || "0.0001");
|
||||
|
||||
let num = match val.parse::<f32>() {
|
||||
Err(_) => return cx.render(rsx!("Parsing failed")),
|
||||
Ok(num) => num,
|
||||
};
|
||||
|
||||
cx.render(rsx! {
|
||||
h1 { "The parsed value is {num}" }
|
||||
button {
|
||||
onclick: move |_| val.set("invalid"),
|
||||
"Set an invalid number"
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user