Fix suspense on resource

This commit is contained in:
Jonathan Kelley committed 2024-02-05 11:59:50 -08:00
1 parent 13cc912aeb
commit 69e4ebe4ed
3 files changed
+20 -23

No files matched your search

+2 -2
View File
@@ -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}" } }