Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client side suspense #1926

Merged
merged 2 commits into from Feb 13, 2024

Conversation

ealmloff
Copy link
Member

@ealmloff ealmloff commented Feb 12, 2024

This PR fixes an infinite loop that happens when suspense starts on the client. Currently suspense causes tasks to stop being polled which makes suspense never resolve and causes an infinite loop. Stacked on #1925.

This example does not work on the git version of dioxus but does work in this PR:

use dioxus::prelude::*;
use serde::{Deserialize, Serialize};

fn app() -> Element {
    let mut count = use_signal(|| 1);

    rsx! {
        button { onclick: move |_| count += 1, "Up high!" }
        for i in 0..count() {
            Child {}
        }
    }
}

fn Child() -> Element {
    let server_future = use_server_future(get_server_data)?;
    rsx! {
        h1 { "Hello, World!" }
        "{server_future.state():?}"
    }
}

#[server]
async fn get_server_data() -> Result<String, ServerFnError> {
    Ok(reqwest::get("https://httpbin.org/ip").await?.text().await?)
}

fn main() {
    launch(app);
}

@ealmloff ealmloff added bug Something isn't working core relating to the core implementation of the virtualdom labels Feb 12, 2024
@jkelleyrtp jkelleyrtp merged commit 49f3b82 into DioxusLabs:master Feb 13, 2024
9 checks passed
@ealmloff ealmloff deleted the fix-client-side-suspense branch February 13, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core relating to the core implementation of the virtualdom
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants