wip: add use_callback hook

This commit is contained in:
Jonathan Kelley committed 2022-11-19 13:21:02 -08:00
1 parent 6c677e64da
commit 57c10174ec
4 files changed
+62 -6

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
use std::rc::Rc;
use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let login = use_callback!(cx, || |evt| async {
//
});
cx.render(rsx! {
button {
onclick: login,
"Click me!"
}
})
}
+4 -4
View File
@@ -1,5 +1,5 @@
use dioxus::prelude::*;
use std::collections::HashMap;
use std::{collections::HashMap, marker::PhantomData};
fn main() {
dioxus_desktop::launch(|cx| {
@@ -65,7 +65,7 @@ async fn breed_pic(cx: Scope, breed: String) -> Element {
});
match fut.await {
Ok(resp) => cx.render(rsx! {
Ok(resp) => render! {
div {
button {
onclick: move |_| fut.restart(),
@@ -77,7 +77,7 @@ async fn breed_pic(cx: Scope, breed: String) -> Element {
max_height: "500px",
}
}
}),
Err(_) => cx.render(rsx! { div { "loading dogs failed" } }),
},
Err(_) => render! { div { "loading dogs failed" } },
}
}