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

Double render of element on use_server_future when using asset!()s #3299

Closed
Andrew15-5 opened this issue Dec 6, 2024 · 1 comment · Fixed by #3287
Closed

Double render of element on use_server_future when using asset!()s #3299

Andrew15-5 opened this issue Dec 6, 2024 · 1 comment · Fixed by #3287
Labels
bug Something isn't working fullstack related to the fullstack crate

Comments

@Andrew15-5
Copy link
Contributor

Problem

Here is a MRE:

...

#[component]
fn App() -> Element {
    rsx! {
        document::Link { rel: "icon", href: asset!("/favicon.ico") } // trigger
        Main { }
    }
}

#[component]
fn Main() -> Element {
    let mut items: Signal<Vec<String>> = use_signal(|| Vec::with_capacity(10));
    let init_db_result = use_server_future(move || async move {
        init_db().await.map(|v| {
            spawn(async move { items.set(v) });
        })
    })?;

    if let Err(err) = init_db_result().unwrap() {
        return Err(RenderError::Aborted(dioxus::CapturedError::from_display(
            err,
        )));
    }

    let all_items = {
        let a = items.read().clone().into_iter().map(|x| rsx! { {x} });
        if a.len() == 0 {
            rsx! { "No items" }
        } else {
            rsx! { {a} }
        }
    };

    rsx! {
     p { "List of items:" }
     ul { {all_items} }
    }
}

...

If I have any asset!s, then I get:

image

If I remove them, then:

image

I tried using #3287 that should potentially fix this.

Steps To Reproduce

Steps to reproduce the behavior:

Expected behavior

The content of ul {} should be rendered once, not twice.

Environment:

  • Dioxus version: 9d6e28b
  • Rust version: 1.83.0-nightly (fb4aebddd 2024-09-30)
  • OS info: Pop!_OS 22.04
  • App platform: web + fullstack
@Andrew15-5
Copy link
Contributor Author

Andrew15-5 commented Dec 7, 2024

Looks like the PR actually fixes this, though I now get panic error almost always, which prevent hot reloading from working. This now has been addressed.

@ealmloff ealmloff added bug Something isn't working fullstack related to the fullstack crate labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fullstack related to the fullstack crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants