wip: add use_callback hook
This commit is contained in:
1 parent
6c677e64da
commit
57c10174ec
4 files changed
+62
-6
No files matched your search
@@ -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
@@ -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" } },
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user