mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 14:44:12 +00:00
Merge pull request #138 from mrxiaozhuox/master
fix: `dog-app` breed change
This commit is contained in:
commit
8c7473d194
1 changed files with 7 additions and 1 deletions
|
@ -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 a new issue