Fix suspense on resource
This commit is contained in:
3 files changed
+20
-23
No files matched your search
@@ -50,7 +50,7 @@ fn app() -> Element {
|
||||
/// Suspense is achieved my moving the future into only the component that
|
||||
/// actually renders the data.
|
||||
fn Doggo() -> Element {
|
||||
let fut = use_future(move || async move {
|
||||
let mut fut = use_resource(move || async move {
|
||||
#[derive(serde::Deserialize)]
|
||||
struct DogApi {
|
||||
message: String,
|
||||
@@ -63,7 +63,7 @@ fn Doggo() -> Element {
|
||||
.await
|
||||
});
|
||||
|
||||
match fut.value().read().as_ref() {
|
||||
match fut.read().as_ref() {
|
||||
Some(Ok(resp)) => rsx! {
|
||||
button { onclick: move |_| fut.restart(), "Click to fetch another doggo" }
|
||||
div { img { max_width: "500px", max_height: "500px", src: "{resp.message}" } }
|
||||
|
||||
Reference in new issue
Block a user