fix: `dog-app` breed change
This commit is contained in:
parent
2073b400df
commit
16d2074fcf
|
@ -61,7 +61,7 @@ fn app(cx: Scope) -> Element {
|
|||
|
||||
#[inline_props]
|
||||
fn Breed(cx: Scope, breed: String) -> Element {
|
||||
#[derive(serde::Deserialize)]
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
struct DogApi {
|
||||
message: String,
|
||||
}
|
||||
|
@ -72,6 +72,12 @@ fn Breed(cx: Scope, breed: String) -> Element {
|
|||
reqwest::get(endpoint).await.unwrap().json::<DogApi>().await
|
||||
});
|
||||
|
||||
let breed_name = use_state(&cx, || breed.clone());
|
||||
if breed_name.get() != breed {
|
||||
breed_name.set(breed.clone());
|
||||
fut.restart();
|
||||
}
|
||||
|
||||
cx.render(match fut.value() {
|
||||
Some(Ok(resp)) => rsx! {
|
||||
button {
|
||||
|
|
Loading…
Reference in New Issue